From 3f50eb91ed9d4e0db9782330ab8c5049f8a56897 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 24 Apr 2024 12:59:40 +0200 Subject: [PATCH 1/2] chore(stage-build): remove misleading ref input --- .github/workflows/stage-build.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index 3f86b098a267..12e82330b660 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -13,7 +13,6 @@ env: DEFAULT_DEPLOYMENT_PREFIX: "main" DEFAULT_NOTES: "" DEFAULT_LOG_EACH_SUCCESSFUL_UPLOAD: "false" - DEFAULT_REF: next on: schedule: @@ -22,10 +21,6 @@ on: workflow_dispatch: inputs: - ref: - description: "Branch to deploy (default: next)" - required: false - notes: description: "Notes" required: false @@ -70,7 +65,7 @@ jobs: if: ${{ github.repository == 'mdn/yari' && github.event.schedule != '' }} steps: # The schedule runs the `main` version, but we want the `next` version. - - run: gh workflow run "${{ github.workflow }}" --repo "${{ github.repository }}" --ref "${{ env.DEFAULT_REF }}" + - run: gh workflow run "${{ github.workflow }}" --repo "${{ github.repository }}" --ref "next" env: GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} @@ -93,15 +88,13 @@ jobs: run: | echo "DEPLOYER_BUCKET_PREFIX=${{ github.event.inputs.deployment_prefix || env.DEFAULT_DEPLOYMENT_PREFIX }}" >> $GITHUB_ENV echo "DEPLOYER_LOG_EACH_SUCCESSFUL_UPLOAD=${{ github.event.inputs.log_each_successful_upload || env.DEFAULT_LOG_EACH_SUCCESSFUL_UPLOAD }}" >> $GITHUB_ENV - echo "REF=${{ github.event.inputs.ref || env.DEFAULT_REF }}" >> $GITHUB_ENV - uses: actions/checkout@v4 with: - ref: ${{ env.REF }} fetch-depth: 0 - name: Merge main - if: ${{ env.REF != 'main' }} + if: ${{ github.ref_name != 'main' }} run: | git config --global user.email "108879845+mdn-bot@users.noreply.github.com" git config --global user.name "mdn-bot" From d0a13fa6a9490acde223edee2a1a9826fe586bdb Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 24 Apr 2024 13:06:39 +0200 Subject: [PATCH 2/2] enhance(stage-build): always trigger on main + build on next --- .github/workflows/stage-build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index 12e82330b660..44735261e8b9 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -62,9 +62,10 @@ permissions: jobs: trigger: runs-on: ubuntu-latest - if: ${{ github.repository == 'mdn/yari' && github.event.schedule != '' }} + + # When run from `main` branch (schedule or manual), trigger workflow on `next` branch instead. + if: ${{ github.repository == 'mdn/yari' && github.ref_name == 'main' }} steps: - # The schedule runs the `main` version, but we want the `next` version. - run: gh workflow run "${{ github.workflow }}" --repo "${{ github.repository }}" --ref "next" env: GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} @@ -73,8 +74,8 @@ jobs: environment: stage runs-on: ubuntu-latest - # Only run the scheduled workflows on the main repo. - if: ${{ github.repository == 'mdn/yari' && github.event.schedule == '' }} + # We only ever want to deploy the `next` branch to stage. + if: ${{ github.repository == 'mdn/yari' && github.ref_name == 'next' }} steps: # Our usecase is a bit complicated. When the cron schedule runs this workflow, @@ -94,7 +95,6 @@ jobs: fetch-depth: 0 - name: Merge main - if: ${{ github.ref_name != 'main' }} run: | git config --global user.email "108879845+mdn-bot@users.noreply.github.com" git config --global user.name "mdn-bot"