1414# ─────────────────────────────────────────────────────────────────────────────
1515#
1616# GitHub Environments (repo Settings → Environments):
17- # rubygems- publish
17+ # publish
1818# - Required reviewers: sdk-eng team or named maintainers
1919# - Prevent self-review: enabled
2020# - Deployment branches: main only
21- # rubygems- publish-dry-run
21+ # publish-dry-run
2222# - Required reviewers: at least yourself (to test the approval gate)
2323# - Allow administrators to bypass: enabled (for testing flexibility)
2424# - Deployment branches: no restriction
3434# Configure for your gem at rubygems.org → gem settings → Trusted Publishers
3535# Repository: braintrustdata/sdk-actions (or your SDK repo)
3636# Workflow: release-ruby.yml (or your workflow filename)
37- # Environment: rubygems- publish
37+ # Environment: publish
3838#
3939# ─────────────────────────────────────────────────────────────────────────────
4040
4141name : Release Ruby (bt-fake)
4242
4343on :
44+ # Auto dry-run on PRs that touch the generated actions or the workflows, to
45+ # smoke-test the actions end-to-end. (A template edited without regenerating
46+ # is caught separately by the CI check-generated job, which runs on every PR.)
47+ pull_request :
48+ paths :
49+ - ' actions/**'
50+ - ' .github/workflows/**'
4451 workflow_dispatch :
4552 inputs :
4653 _instructions :
@@ -109,8 +116,8 @@ jobs:
109116 # version_file: lib/your_gem/version.rb
110117 # version_module: YourGem
111118 version : ${{ needs.bump.outputs.version }}
112- sha : ${{ inputs.sha }}
113- dry_run : ${{ inputs.dry_run }}
119+ sha : ${{ inputs.sha || github.event.pull_request.head.sha }}
120+ dry_run : ${{ inputs.dry_run || github.event_name == 'pull_request' }}
114121 working_directory : test/release/ruby
115122
116123 prepare :
@@ -133,8 +140,11 @@ jobs:
133140 uses : ./actions/release/prepare
134141 with :
135142 release_tag : ${{ needs.validate.outputs.release_tag }}
136- sha : ${{ inputs.sha }}
137- prev_release : ${{ inputs.prev_release || needs.validate.outputs.prev_release }}
143+ sha : ${{ inputs.sha || github.event.pull_request.head.sha }}
144+ # On PR auto dry-runs, anchor notes to the head SHA: prepare treats a
145+ # full SHA as "notes unavailable" (no tag range), so the changelog
146+ # doesn't accumulate in the step summary on every PR.
147+ prev_release : ${{ inputs.prev_release || github.event.pull_request.head.sha || needs.validate.outputs.prev_release }}
138148
139149 notify-pending :
140150 needs : [validate, prepare]
@@ -148,32 +158,42 @@ jobs:
148158 - name : Notify release pending
149159 uses : ./actions/release/notify-pending
150160 with :
151- sha : ${{ inputs.sha }}
161+ sha : ${{ inputs.sha || github.event.pull_request.head.sha }}
152162 release_tag : ${{ needs.validate.outputs.release_tag }}
153163 prev_release : ${{ needs.validate.outputs.prev_release }}
154164 branch : ${{ needs.validate.outputs.branch }}
155165 on_release_branch : ${{ needs.validate.outputs.on_release_branch }}
156166 commit_message : ${{ needs.validate.outputs.commit_message }}
157167 pr_list : ${{ needs.prepare.outputs.pr_list }}
158168 notes : ${{ needs.prepare.outputs.notes }}
159- dry_run : ${{ inputs.dry_run }}
160- slack_token : ${{ secrets.SLACK_BOT_TOKEN }}
161- slack_channel : ${{ vars.SLACK_SDK_RELEASE_CHANNEL }}
169+ dry_run : ${{ inputs.dry_run || github.event_name == 'pull_request' }}
170+ # Suppress Slack on PR auto dry-runs (still exercises message-building; just no real post).
171+ # Gate on != pull_request: GHA's `A && '' || B` returns B (the '' is falsy), so suppression
172+ # must be the trailing '' branch, not the "true" value.
173+ slack_token : ${{ github.event_name != 'pull_request' && secrets.SLACK_BOT_TOKEN || '' }}
174+ slack_channel : ${{ github.event_name != 'pull_request' && vars.SLACK_SDK_RELEASE_CHANNEL || '' }}
162175 # slack_mention: '@sdk-eng'
163176 emoji : ' :ruby:'
164177
165178 publish :
166179 needs : [bump, validate, prepare, notify-pending]
167180 runs-on : ubuntu-24.04
168181 timeout-minutes : 15
169- environment : ${{ inputs.dry_run && 'rubygems-publish-dry-run' || 'rubygems-publish' }}
182+ # No environment on PR dry-runs (avoids the approval gate AND the accumulating
183+ # deployment records); the gated environments apply only to manual dispatch.
184+ # Note the structure: empty must be the trailing `|| ''` branch, since GHA's
185+ # `cond && '' || X` would fall through to X (the '' is falsy).
186+ environment : >-
187+ ${{ github.event_name != 'pull_request'
188+ && (inputs.dry_run && 'publish-dry-run' || 'publish')
189+ || '' }}
170190 permissions :
171191 contents : write
172192 id-token : write
173193 steps :
174194 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
175195 with :
176- ref : ${{ inputs.sha }}
196+ ref : ${{ inputs.sha || github.event.pull_request.head.sha }}
177197 fetch-depth : 0
178198
179199 # bt-fake: update both version.rb and Gemfile.lock to the run-number version.
@@ -191,19 +211,22 @@ jobs:
191211 - name : Publish
192212 uses : ./actions/release/lang/ruby/publish
193213 with :
194- sha : ${{ inputs.sha }}
214+ sha : ${{ inputs.sha || github.event.pull_request.head.sha }}
195215 checkout : ' false' # bt-fake: skip internal checkout — version patching above must survive into the gem build
196216 working_directory : test/release/ruby
197- dry_run : ${{ inputs.dry_run }}
217+ dry_run : ${{ inputs.dry_run || github.event_name == 'pull_request' }}
198218 release_tag : ${{ needs.validate.outputs.release_tag }}
199219 github_release : ' false' # bt-fake: omit GitHub release to avoid tag/release pollution from repeated test runs
200220 notes : ${{ needs.prepare.outputs.notes }}
201221 prev_release : ${{ needs.validate.outputs.prev_release }}
202222 branch : ${{ needs.validate.outputs.branch }}
203223 on_release_branch : ${{ needs.validate.outputs.on_release_branch }}
204224 pr_list : ${{ needs.prepare.outputs.pr_list }}
205- slack_token : ${{ secrets.SLACK_BOT_TOKEN }}
206- slack_channel : ${{ vars.SLACK_SDK_RELEASE_CHANNEL }}
225+ # Suppress Slack on PR auto dry-runs (still exercises message-building; just no real post).
226+ # Gate on != pull_request: GHA's `A && '' || B` returns B (the '' is falsy), so suppression
227+ # must be the trailing '' branch, not the "true" value.
228+ slack_token : ${{ github.event_name != 'pull_request' && secrets.SLACK_BOT_TOKEN || '' }}
229+ slack_channel : ${{ github.event_name != 'pull_request' && vars.SLACK_SDK_RELEASE_CHANNEL || '' }}
207230 # slack_mention: '@sdk-eng'
208231 # failure_slack_mention: '@sdk-eng'
209232 gem_name : bt-fake
0 commit comments