Unverified Commit c7ddb164 authored by Julian Antonielli's avatar Julian Antonielli Committed by GitHub
Browse files

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
parent aa60badf
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ env:
  rust_version: 1.61.0

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

jobs:
  main-branch-check:
    name: Check that workflow is running in main
    runs-on: ubuntu-latest
    steps:
    - name: Main branch check
      if: ${{ github.ref_name != 'main' }}
      uses: actions/github-script@v6
      with:
        script: |
          core.setFailed("The release workflow can only be ran on main (current branch: ${{ github.ref_name }})")

  # If a release is kicked off before an image is built after push to main,
  # or if a dry-run release is kicked off against a non-main branch to test
  # automation changes, we'll need to build a base image to work against.
  # This job will be a no-op if an image was already built on main.
  acquire-base-image:
    name: Acquire Base Image
    needs:
    - main-branch-check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3