From 8091ab940d084f3b2b7fae6f5ab15ed6e63a9256 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 16 Apr 2024 15:47:32 +0200 Subject: [PATCH 1/3] feat(stage-build): deploy next with main merged --- .github/workflows/stage-build.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index ff3e9ee6a86b..cc1d2a5f348e 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -13,6 +13,7 @@ env: DEFAULT_DEPLOYMENT_PREFIX: "main" DEFAULT_NOTES: "" DEFAULT_LOG_EACH_SUCCESSFUL_UPLOAD: "false" + DEFAULT_REF: next on: schedule: @@ -21,6 +22,10 @@ on: workflow_dispatch: inputs: + ref: + description: "Branch to deploy (default: next)" + required: false + notes: description: "Notes" required: false @@ -69,6 +74,21 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.ref || env.DEFAULT_REF }} + fetch-depth: 0 + + - name: Merge main + if: ${{ (github.event.inputs.ref || env.DEFAULT_REF) != 'main' }} + run: | + git config --global user.email "108879845+mdn-bot@users.noreply.github.com" + git config --global user.name "mdn-bot" + git status + git pull + git checkout main + git status + git checkout - + git merge main --no-edit - uses: actions/checkout@v4 if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }} From 2423b73439251d238f59616124d6486138508437 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 16 Apr 2024 15:57:10 +0200 Subject: [PATCH 2/3] refactor(stage-build): move merge step up --- .github/workflows/stage-build.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index cc1d2a5f348e..127e777a861b 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -73,6 +73,18 @@ jobs: if: github.repository == 'mdn/yari' steps: + # Our usecase is a bit complicated. When the cron schedule runs this workflow, + # we rely on the env vars defined at the top of the file. But if it's a manual + # trigger we rely on the inputs and only the inputs. That way, the user can + # opt to type in 'false'. + # It's not possible to express this with GitHub Workflow syntax, so we + # have a dedicate set that conveniently sets these as env vars which we + # can refer to later in `if: ....` lines or in bash with the `run: ...` blocks. + - name: Merge dispatch inputs with default env vars + 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 + - uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.ref || env.DEFAULT_REF }} @@ -115,18 +127,6 @@ jobs: repository: mdn/curriculum path: mdn/curriculum - # Our usecase is a bit complicated. When the cron schedule runs this workflow, - # we rely on the env vars defined at the top of the file. But if it's a manual - # trigger we rely on the inputs and only the inputs. That way, the user can - # opt to type in 'false'. - # It's not possible to express this with GitHub Workflow syntax, so we - # have a dedicate set that conveniently sets these as env vars which we - # can refer to later in `if: ....` lines or in bash with the `run: ...` blocks. - - name: Merge dispatch inputs with default env vars - 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 - - uses: actions/checkout@v4 if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }} with: From b25555133b3557fd5874e580c42e2e2f848e391d Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 16 Apr 2024 15:58:21 +0200 Subject: [PATCH 3/3] refactor(stage-build): introduce REF env var --- .github/workflows/stage-build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index 127e777a861b..4db7e1155a86 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -84,14 +84,15 @@ 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: ${{ github.event.inputs.ref || env.DEFAULT_REF }} + ref: ${{ env.REF }} fetch-depth: 0 - name: Merge main - if: ${{ (github.event.inputs.ref || env.DEFAULT_REF) != 'main' }} + if: ${{ env.REF != 'main' }} run: | git config --global user.email "108879845+mdn-bot@users.noreply.github.com" git config --global user.name "mdn-bot"