Skip to content

Commit c7ddb16

Browse files
authored
Check that release workflow is run on main (#1856)
* Announce whether the release script is running in dry_run mode or not * Check that release is running in main branch * Fix `run_name` -> `run-name` * Import actions/github-script@v6 in main-branch-check * Add missing `steps` attribute in main-branch-check * Use `with` attribute with actions/github-script@v6 * Use single quotes instead of double quotes * Use single quotes: "main" -> 'main' * Add runs-on attribute
1 parent aa60bad commit c7ddb16

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/release.yml

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
rust_version: 1.61.0
1414

1515
name: Release smithy-rs
16+
run-name: ${{ github.workflow }} - ${{ inputs.dry_run && 'Dry run' || 'Production run' }}
1617
on:
1718
workflow_dispatch:
1819
inputs:
@@ -23,12 +24,25 @@ on:
2324
default: true
2425

2526
jobs:
27+
main-branch-check:
28+
name: Check that workflow is running in main
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Main branch check
32+
if: ${{ github.ref_name != 'main' }}
33+
uses: actions/github-script@v6
34+
with:
35+
script: |
36+
core.setFailed("The release workflow can only be ran on main (current branch: ${{ github.ref_name }})")
37+
2638
# If a release is kicked off before an image is built after push to main,
2739
# or if a dry-run release is kicked off against a non-main branch to test
2840
# automation changes, we'll need to build a base image to work against.
2941
# This job will be a no-op if an image was already built on main.
3042
acquire-base-image:
3143
name: Acquire Base Image
44+
needs:
45+
- main-branch-check
3246
runs-on: ubuntu-latest
3347
steps:
3448
- uses: actions/checkout@v3

0 commit comments

Comments
 (0)