From 0eec258c01ce2bd8e011d2c965d6b255a1208121 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Thu, 18 Mar 2021 14:31:31 -0500 Subject: [PATCH] Fix git branch inconsistencies for Actions (#18309) * Update workflows to pass appropriate branch name for pull_request events * Update Docker building workflow to check appropriate branch name for pull_request events * Update Windows testing workflow for consistency with non-Windows testing workflow * Reorder if conditional check * Update workflow comment --- .github/workflows/build-docker-image.yml | 2 +- .github/workflows/link-check-dotcom.yml | 2 +- .github/workflows/link-check-ghae.yml | 2 +- .github/workflows/link-check-ghes.yml | 2 +- .github/workflows/test-windows.yml | 19 +++++++++++++++++-- .github/workflows/test.yml | 2 +- script/early-access/clone-for-build.js | 2 +- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index dda06fef44..33ab553694 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -14,7 +14,7 @@ env: jobs: build: # Do not run this job for translations PRs - if: ${{ github.ref != 'refs/heads/translations' }} + if: ${{ github.head_ref != 'translations' && github.ref != 'refs/heads/translations' }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/link-check-dotcom.yml b/.github/workflows/link-check-dotcom.yml index bb057dd262..bee98f6380 100644 --- a/.github/workflows/link-check-dotcom.yml +++ b/.github/workflows/link-check-dotcom.yml @@ -47,7 +47,7 @@ jobs: # run: npm run heroku-postbuild # env: # DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} - # GIT_BRANCH: ${{ github.ref }} + # GIT_BRANCH: ${{ github.head_ref || github.ref }} - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} name: Build diff --git a/.github/workflows/link-check-ghae.yml b/.github/workflows/link-check-ghae.yml index ea35077e55..a94d939510 100644 --- a/.github/workflows/link-check-ghae.yml +++ b/.github/workflows/link-check-ghae.yml @@ -47,7 +47,7 @@ jobs: # run: npm run heroku-postbuild # env: # DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} - # GIT_BRANCH: ${{ github.ref }} + # GIT_BRANCH: ${{ github.head_ref || github.ref }} - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} name: Build diff --git a/.github/workflows/link-check-ghes.yml b/.github/workflows/link-check-ghes.yml index 36ed88e942..5049c89d0e 100644 --- a/.github/workflows/link-check-ghes.yml +++ b/.github/workflows/link-check-ghes.yml @@ -47,7 +47,7 @@ jobs: # run: npm run heroku-postbuild # env: # DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} - # GIT_BRANCH: ${{ github.ref }} + # GIT_BRANCH: ${{ github.head_ref || github.ref }} - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }} name: Build diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index a30d60173a..7f2042634f 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -1,4 +1,4 @@ -# NOTE: Changes to this file should also be applied to './test.yml' and './test-translations.yml' +# NOTE: Changes to this file should also be applied to './test.yml' name: Node.js Tests - Windows @@ -8,10 +8,14 @@ on: schedule: - cron: '50 19 * * *' # once a day at 19:50 UTC / 11:50 PST +env: + CI: true + jobs: test: runs-on: windows-latest if: (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'Windows') || contains(github.event.pull_request.labels.*.name, 'windows'))) + timeout-minutes: 60 strategy: fail-fast: false matrix: @@ -19,6 +23,9 @@ jobs: steps: - name: Check out repo uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f + with: + # Enables cloning the Early Access repo later with the relevant PAT + persist-credentials: 'false' - name: Setup node uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e @@ -41,7 +48,15 @@ jobs: - name: Install dependencies run: npm ci - - name: Run build script + - if: ${{ github.repository == 'github/docs-internal' }} + name: Clone early access + run: npm run heroku-postbuild + env: + DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} + GIT_BRANCH: ${{ github.head_ref || github.ref }} + + - if: ${{ github.repository != 'github/docs-internal' }} + name: Run build script run: npm run build - name: Run tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 978b6ed29b..ab5f8d14fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: run: npm run heroku-postbuild env: DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} - GIT_BRANCH: ${{ github.ref }} + GIT_BRANCH: ${{ github.head_ref || github.ref }} - if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' && github.repository != 'github/docs-internal' }} name: Run build script diff --git a/script/early-access/clone-for-build.js b/script/early-access/clone-for-build.js index 6ba9fbebdb..6bf2cf239d 100755 --- a/script/early-access/clone-for-build.js +++ b/script/early-access/clone-for-build.js @@ -12,7 +12,7 @@ require('dotenv').config() const { DOCUBOT_REPO_PAT, HEROKU_PRODUCTION_APP, - GIT_BRANCH // Set by the deployer with the name of the docs-internal branch + GIT_BRANCH // Set by Actions and/or the deployer with the name of the docs-internal branch } = process.env // Exit if PAT is not found