Skip to content

Commit 2599d72

Browse files
authored
conditionally clone docs-early-access by branchname (#24674)
* conditionally clone docs-early-access by branchname * fix path * right api * the correct use of Octokit * try that * destructuring total_count * test early access with fs.existsSync * debugging * bad lookup * better lookup technique * trying something * always check it out * with debugging * with token * with path * better * go for it * only on docs-internal * better name * formatting * tidying up * correct octokit * feedbacked * correct hopefully * final version * disable test that checks for perfect translation-to-English file parity * Accidentally committed in the wrong branch. This reverts commit adee780718ea7414934e2257d17b0c004bd804af. * match the azure-preview-env-deploy.yml
1 parent 486c889 commit 2599d72

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

.github/workflows/test.yml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,52 @@ jobs:
5151
# Enables cloning the Early Access repo later with the relevant PAT
5252
persist-credentials: 'false'
5353

54+
- name: Figure out which docs-early-access branch to checkout, if internal repo
55+
if: ${{ github.repository == 'github/docs-internal' }}
56+
id: check-early-access
57+
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
58+
env:
59+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
60+
with:
61+
github-token: ${{ secrets.DOCUBOT_REPO_PAT }}
62+
result-encoding: string
63+
script: |
64+
// If being run from a PR, this becomes 'my-cool-branch'.
65+
// If run on main, with the `workflow_dispatch` action for
66+
// example, the value becomes 'main'.
67+
const { BRANCH_NAME } = process.env
68+
try {
69+
const response = await github.repos.getBranch({
70+
owner: 'github',
71+
repo: 'docs-early-access',
72+
BRANCH_NAME,
73+
})
74+
console.log(`Using docs-early-access branch called '${BRANCH_NAME}'.`)
75+
return BRANCH_NAME
76+
} catch (err) {
77+
if (err.status === 404) {
78+
console.log(`There is no docs-early-access branch called '${BRANCH_NAME}' so checking out 'main' instead.`)
79+
return 'main'
80+
}
81+
throw err
82+
}
83+
84+
- name: Check out docs-early-access too, if internal repo
85+
if: ${{ github.repository == 'github/docs-internal' }}
86+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
87+
with:
88+
repository: github/docs-early-access
89+
token: ${{ secrets.DOCUBOT_REPO_PAT }}
90+
path: docs-early-access
91+
ref: ${{ steps.check-early-access.outputs.result }}
92+
93+
- name: Merge docs-early-access repo's folders
94+
run: |
95+
mv docs-early-access/assets assets/images/early-access
96+
mv docs-early-access/content content/early-access
97+
mv docs-early-access/data data/early-access
98+
rm -r docs-early-access
99+
54100
- name: Checkout LFS objects
55101
run: git lfs checkout
56102

@@ -78,13 +124,6 @@ jobs:
78124
- name: Install dependencies
79125
run: npm ci
80126

81-
- name: Clone early access
82-
if: ${{ github.repository == 'github/docs-internal' }}
83-
run: script/early-access/clone-for-build.js
84-
env:
85-
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
86-
GIT_BRANCH: ${{ github.head_ref || github.ref }}
87-
88127
- name: Cache nextjs build
89128
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
90129
with:

tests/rendering/breadcrumbs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getDOM, getJSON } from '../helpers/supertest.js'
22
import { jest } from '@jest/globals'
33

4+
// TODO: Use `describeViaActionsOnly` instead. See tests/rendering/server.js
45
const describeInternalOnly =
56
process.env.GITHUB_REPOSITORY === 'github/docs-internal' ? describe : describe.skip
67
// Breadcrumbs were moved to the Header and in the Menu for mobile, so there are now double the Breadcrumbs

0 commit comments

Comments
 (0)