diff --git a/.github/actions/get-docs-early-access/action.yml b/.github/actions/get-docs-early-access/action.yml new file mode 100644 index 0000000000..85a61a2ba2 --- /dev/null +++ b/.github/actions/get-docs-early-access/action.yml @@ -0,0 +1,33 @@ +name: Clone and add docs-early-access + +description: Clone docs-early-access and copy its content into the repo + +inputs: + token: + description: PAT + required: true + +runs: + using: 'composite' + steps: + - name: Figure out which branch to checkout + id: check-early-access + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + GITHUB_TOKEN: ${{ inputs.token }} + shell: bash + run: node .github/actions-scripts/what-docs-early-access-branch.js + + - name: Clone + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + with: + repository: github/docs-early-access + token: ${{ inputs.token }} + path: docs-early-access + ref: ${{ steps.check-early-access.outputs.branch }} + + - name: Merge docs-early-access repo's folders + shell: bash + run: | + .github/actions-scripts/merge-early-access.sh + rm -fr docs-early-access diff --git a/.github/workflows/azure-preview-env-deploy.yml b/.github/workflows/azure-preview-env-deploy.yml index 18d74a74d2..fcf5b57977 100644 --- a/.github/workflows/azure-preview-env-deploy.yml +++ b/.github/workflows/azure-preview-env-deploy.yml @@ -47,9 +47,9 @@ jobs: # See https://bit.ly/3qB9nZW > If a job in a workflow is skipped due to a conditional, it will report its status as "Success". if: | ( - (github.event.pull_request.head.sha || github.event.inputs.COMMIT_REF) + (github.event.pull_request.head.sha || github.event.inputs.COMMIT_REF) && (github.event.number || github.event.inputs.PR_NUMBER || github.run_id) - ) + ) && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') && github.actor != 'dependabot[bot]' timeout-minutes: 15 @@ -110,48 +110,10 @@ jobs: # Image tag is unique to each workflow run so that it always triggers a new deployment echo "DOCKER_IMAGE=${{ secrets.NONPROD_REGISTRY_SERVER }}/${IMAGE_REPO}:${{ env.COMMIT_REF }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV - - if: ${{ env.IS_INTERNAL_BUILD == 'true' }} - name: Determine which docs-early-access branch to clone - id: 'check-early-access' - uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 - env: - BRANCH_NAME: ${{ env.BRANCH_NAME }} + - uses: ./.github/actions/get-docs-early-access + if: ${{ env.IS_INTERNAL_BUILD == 'true' }} with: - github-token: ${{ secrets.DOCUBOT_REPO_PAT }} - result-encoding: string - script: | - const { BRANCH_NAME } = process.env - - try { - const { status } = await github.request('GET /repos/{owner}/{repo}/branches/{branch}', { - owner: 'github', - repo: 'docs-early-access', - branch: BRANCH_NAME, - }) - - if (status !== 200) { - throw new Error('Received non-200 response from branch GET request') - } - - console.log(`Using docs-early-access branch '${BRANCH_NAME}'`) - return BRANCH_NAME - } catch (e) { - console.log(`Failed to get docs-early-access branch '${BRANCH_NAME}', 'main' will be used instead.`) - return 'main' - } - - - if: ${{ env.IS_INTERNAL_BUILD == 'true' }} - name: Clone docs-early-access - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: ${{ steps.check-early-access.outputs.result }} - - - if: ${{ env.IS_INTERNAL_BUILD == 'true' }} - name: Merge docs-early-access repo's folders - run: .github/actions-scripts/merge-early-access.sh - if: ${{ env.IS_PUBLIC_BUILD == 'true' }} name: Check out user code to temp directory diff --git a/.github/workflows/azure-prod-build-deploy.yml b/.github/workflows/azure-prod-build-deploy.yml index 95a148f87a..7b6befcd0a 100644 --- a/.github/workflows/azure-prod-build-deploy.yml +++ b/.github/workflows/azure-prod-build-deploy.yml @@ -61,15 +61,9 @@ jobs: node-version-file: 'package.json' cache: npm - - name: Clone docs-early-access - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: ./.github/actions/get-docs-early-access with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - - - name: Merge docs-early-access repo's folders - run: .github/actions-scripts/merge-early-access.sh - uses: ./.github/actions/clone-translations with: diff --git a/.github/workflows/azure-staging-build-deploy.yml b/.github/workflows/azure-staging-build-deploy.yml index 755f3829f0..371eec07cf 100644 --- a/.github/workflows/azure-staging-build-deploy.yml +++ b/.github/workflows/azure-staging-build-deploy.yml @@ -79,16 +79,9 @@ jobs: node-version-file: 'package.json' cache: npm - - name: Clone docs-early-access - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: ./.github/actions/get-docs-early-access with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: main - - - name: Merge docs-early-access repo's folders - run: .github/actions-scripts/merge-early-access.sh - name: 'Build and push image' uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index bc046045fa..4631fe15be 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -65,6 +65,11 @@ jobs: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true run: npm ci --include=optional + - uses: ./.github/actions/get-docs-early-access + if: ${{ github.repository == 'github/docs-internal' }} + with: + token: ${{ secrets.DOCUBOT_REPO_PAT }} + - name: Cache nextjs build uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 with: diff --git a/.github/workflows/check-broken-links-github-github.yml b/.github/workflows/check-broken-links-github-github.yml index ecb9b7a439..0e839543d4 100644 --- a/.github/workflows/check-broken-links-github-github.yml +++ b/.github/workflows/check-broken-links-github-github.yml @@ -44,19 +44,12 @@ jobs: # To prevent issues with cloning early access content later persist-credentials: 'false' - - name: Clone docs-early-access - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - with: - repository: github/docs-early-access - token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: main - - - name: Merge docs-early-access repo's folders - run: .github/actions-scripts/merge-early-access.sh - - uses: ./.github/actions/node-npm-setup + - uses: ./.github/actions/get-docs-early-access + with: + token: ${{ secrets.DOCUBOT_REPO_PAT }} + - name: Build server run: npm run build diff --git a/.github/workflows/link-check-daily.yml b/.github/workflows/link-check-daily.yml index 72a6dc3e67..0e2015c936 100644 --- a/.github/workflows/link-check-daily.yml +++ b/.github/workflows/link-check-daily.yml @@ -27,26 +27,10 @@ jobs: - uses: ./.github/actions/node-npm-setup - - name: Figure out which docs-early-access branch to checkout, if internal repo + - uses: ./.github/actions/get-docs-early-access if: ${{ github.repository == 'github/docs-internal' }} - id: check-early-access - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }} - run: node .github/actions-scripts/what-docs-early-access-branch.js - - - name: Check out docs-early-access too, if internal repo - if: ${{ github.repository == 'github/docs-internal' }} - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: ${{ steps.check-early-access.outputs.branch }} - - - name: Merge docs-early-access repo's folders - if: ${{ github.repository == 'github/docs-internal' }} - run: .github/actions-scripts/merge-early-access.sh - name: Restore disk-cache file for external link checking uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 diff --git a/.github/workflows/link-check-on-pr.yml b/.github/workflows/link-check-on-pr.yml index 8efb2ca526..16ea0a4f9d 100644 --- a/.github/workflows/link-check-on-pr.yml +++ b/.github/workflows/link-check-on-pr.yml @@ -30,26 +30,10 @@ jobs: - uses: ./.github/actions/node-npm-setup - - name: Figure out which docs-early-access branch to checkout, if internal repo + - uses: ./.github/actions/get-docs-early-access if: ${{ github.repository == 'github/docs-internal' }} - id: check-early-access - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }} - run: node .github/actions-scripts/what-docs-early-access-branch.js - - - name: Check out docs-early-access too, if internal repo - if: ${{ github.repository == 'github/docs-internal' }} - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: ${{ steps.check-early-access.outputs.branch }} - - - name: Merge docs-early-access repo's folders - if: ${{ github.repository == 'github/docs-internal' }} - run: .github/actions-scripts/merge-early-access.sh # TODO: When we want to fix redirects on changed files we can uncomment everything below # Creates file "${{ env.HOME }}/files.json", among others diff --git a/.github/workflows/main-preview-docker-cache.yml b/.github/workflows/main-preview-docker-cache.yml index 85e1f48b71..201b704481 100644 --- a/.github/workflows/main-preview-docker-cache.yml +++ b/.github/workflows/main-preview-docker-cache.yml @@ -50,18 +50,10 @@ jobs: # To prevent issues with cloning early access content later persist-credentials: 'false' - - if: ${{ env.ENABLE_EARLY_ACCESS }} - name: Clone docs-early-access - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: ./.github/actions/get-docs-early-access + if: ${{ env.ENABLE_EARLY_ACCESS }} with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: main - - - if: ${{ env.ENABLE_EARLY_ACCESS }} - name: Merge docs-early-access repo's folders - run: .github/actions-scripts/merge-early-access.sh # In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context - name: 'Prune for preview env' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 492c27ee65..a4a072b548 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,28 +88,10 @@ jobs: - uses: ./.github/actions/node-npm-setup - - name: Figure out which docs-early-access branch to checkout, if internal repo + - uses: ./.github/actions/get-docs-early-access if: ${{ github.repository == 'github/docs-internal' }} - id: check-early-access - env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }} - run: node .github/actions-scripts/what-docs-early-access-branch.js - - - name: Check out docs-early-access too, if internal repo - if: ${{ github.repository == 'github/docs-internal' }} - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: - repository: github/docs-early-access token: ${{ secrets.DOCUBOT_REPO_PAT }} - path: docs-early-access - ref: ${{ steps.check-early-access.outputs.branch }} - - - name: Merge docs-early-access repo's folders - if: ${{ github.repository == 'github/docs-internal' }} - run: | - .github/actions-scripts/merge-early-access.sh - rm -fr docs-early-access - name: Check the test fixture data (if applicable) if: ${{ matrix.test-group == 'rendering-fixtures' }}