Skip to content

Commit 80a2278

Browse files
authored
Merge pull request #15261 from github/repo-sync
repo sync
2 parents 9b110d2 + e2c83d6 commit 80a2278

187 files changed

Lines changed: 778 additions & 614 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/javascript-node
3+
// -
34
{
45
"name": "docs.github.com",
56
"build": {

.github/actions-scripts/content-changes-table-comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ for (const file of articleFiles) {
3636
const sourceUrl = file.blob_url
3737
const fileName = file.filename.slice(pathPrefix.length)
3838
const fileUrl = fileName.slice(0, fileName.lastIndexOf('.'))
39-
const previewLink = `https://${APP_URL}/${fileUrl}`
39+
const previewLink = `${APP_URL}/${fileUrl}`
4040
const productionLink = `https://docs.github.com/${fileUrl}`
4141
let markdownLine = ''
4242

.github/actions-scripts/get-preview-app-info.sh

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,28 @@
1010
[[ -z $GITHUB_REPOSITORY ]] && { echo "Missing GITHUB_REPOSITORY. Exiting."; exit 1; }
1111
[[ -z $PR_NUMBER ]] && { echo "Missing PR_NUMBER. Exiting."; exit 1; }
1212
[[ -z $GITHUB_ENV ]] && { echo "Missing GITHUB_ENV. Exiting."; exit 1; }
13+
[[ -z $APP_NAME_SEED ]] && { echo "Missing APP_NAME_SEED. Exiting."; exit 1; }
1314

14-
# Number of resource groups that we use to split preview envs across
15-
PREVIEW_ENV_RESOURCE_GROUPS=4
15+
PREVIEW_ENV_LOCATION="eastus"
16+
echo "PREVIEW_ENV_LOCATION=${PREVIEW_ENV_LOCATION}" >> $GITHUB_ENV
1617

1718
REPO_NAME="${GITHUB_REPOSITORY#*\/}"
1819
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
1920

2021
DEPLOYMENT_NAME="${REPO_NAME}-pr-${PR_NUMBER}"
2122
echo "DEPLOYMENT_NAME=${DEPLOYMENT_NAME}" >> $GITHUB_ENV
2223

23-
RESOURCE_GROUP="preview-env-${REPO_NAME}-$((${PR_NUMBER} % ${PREVIEW_ENV_RESOURCE_GROUPS}))"
24-
echo "RESOURCE_GROUP=${RESOURCE_GROUP}" >> $GITHUB_ENV
24+
APP_NAME_BASE="${REPO_NAME}-preview-${PR_NUMBER}"
25+
echo "APP_NAME_BASE=${APP_NAME_BASE}" >> $GITHUB_ENV
2526

26-
APP_NAME_SHORT="${REPO_NAME}-preview-${PR_NUMBER}"
27-
echo "APP_NAME_SHORT=${APP_NAME_SHORT}" >> $GITHUB_ENV
27+
# pseudo random string so guessing a preview env URL is more difficult
28+
APP_SHA=$(echo -n "${APP_NAME_SEED}-${APP_NAME_BASE}" | sha1sum | cut -c1-6)
2829

29-
IMAGE_REPO="${GITHUB_REPOSITORY}/pr-${PR_NUMBER}"
30-
echo "IMAGE_REPO=${IMAGE_REPO}" >> $GITHUB_ENV
31-
32-
# Since this incurs a network request and can be slow, we make it optional
33-
if [ $FULL_APP_INFO ]; then
34-
APP_INFO=$(az webapp list -g ${RESOURCE_GROUP} --query "[?tags.DocsAppName == '${APP_NAME_SHORT}'].{defaultHostName:defaultHostName, name:name} | [0]")
30+
APP_NAME="${APP_NAME_BASE}-${APP_SHA}"
31+
echo "APP_NAME=${APP_NAME}" >> $GITHUB_ENV
3532

36-
APP_URL=$(echo $APP_INFO | jq '.defaultHostName' | tr -d '"')
37-
echo "APP_URL=${APP_URL}" >> $GITHUB_ENV
33+
APP_URL="https://${APP_NAME}.${PREVIEW_ENV_LOCATION}.azurecontainer.io"
34+
echo "APP_URL=${APP_URL}" >> $GITHUB_ENV
3835

39-
APP_NAME_FULL=$(echo $APP_INFO | jq '.name' | tr -d '"')
40-
echo "APP_NAME_FULL=${APP_NAME_FULL}" >> $GITHUB_ENV
41-
fi
36+
IMAGE_REPO="${GITHUB_REPOSITORY}/pr-${PR_NUMBER}"
37+
echo "IMAGE_REPO=${IMAGE_REPO}" >> $GITHUB_ENV

.github/workflows/azure-preview-env-deploy.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ jobs:
4040
timeout-minutes: 15
4141
environment:
4242
name: preview-env-${{ github.event.number }}
43-
url: ${{ steps.deploy.outputs.defaultHostName }}
43+
# The environment variable is computer later in this job in
44+
# the "Get preview app info" step.
45+
# That script sets environment variables which is used by Actions
46+
# to link a PR to a list of environments later.
47+
url: ${{ env.APP_URL }}
4448
env:
4549
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER }}
46-
NONPROD_REGISTRY_USERNAME: ghdocs
47-
APP_LOCATION: eastus
4850
ENABLE_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
4951

5052
steps:
@@ -57,7 +59,7 @@ jobs:
5759
uses: azure/docker-login@81744f9799e7eaa418697cb168452a2882ae844a
5860
with:
5961
login-server: ${{ secrets.NONPROD_REGISTRY_SERVER }}
60-
username: ${{ env.NONPROD_REGISTRY_USERNAME }}
62+
username: ${{ secrets.NONPROD_REGISTRY_USERNAME }}
6163
password: ${{ secrets.NONPROD_REGISTRY_PASSWORD }}
6264

6365
- name: Set up Docker Buildx
@@ -75,6 +77,8 @@ jobs:
7577
run: git lfs checkout
7678

7779
- name: Get preview app info
80+
env:
81+
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
7882
run: .github/actions-scripts/get-preview-app-info.sh
7983

8084
- name: 'Set env vars'
@@ -144,23 +148,24 @@ jobs:
144148
# Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel)
145149
- name: 'Cancel any existing deployments for this PR'
146150
run: |
147-
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ env.RESOURCE_GROUP }} || true
151+
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} || true
148152
149153
# Deploy ARM template is idempotent
150154
# Note: once the resources exist the image tag must change for a new deployment to occur (the image tag includes workflow run number, run attempt, as well as sha)
151155
- name: Run ARM deploy
152156
id: deploy
153157
uses: azure/arm-deploy@841b12551939c88af8f6df767c24c38a5620fd0d
154158
with:
155-
resourceGroupName: ${{ env.RESOURCE_GROUP }}
159+
resourceGroupName: ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }}
156160
subscriptionId: ${{ secrets.NONPROD_SUBSCRIPTION_ID }}
157161
template: ./azure-preview-env-template.json
158162
deploymentName: ${{ env.DEPLOYMENT_NAME }}
159-
parameters: appName="${{ env.APP_NAME_SHORT }}"
160-
location="${{ env.APP_LOCATION }}"
161-
linuxFxVersion="DOCKER|${{ env.DOCKER_IMAGE }}"
162-
dockerRegistryUrl="https://${{ secrets.NONPROD_REGISTRY_SERVER }}"
163-
dockerRegistryUsername="${{ env.NONPROD_REGISTRY_USERNAME }}"
163+
parameters: appName="${{ env.APP_NAME }}"
164+
location="${{ env.PREVIEW_ENV_LOCATION }}"
165+
containerImage="${{ env.DOCKER_IMAGE }}"
166+
dockerRegistryUrl="${{ secrets.NONPROD_REGISTRY_SERVER }}"
167+
dockerRegistryUsername="${{ secrets.NONPROD_REGISTRY_USERNAME }}"
164168
dockerRegistryPassword="${{ secrets.NONPROD_REGISTRY_PASSWORD }}"
165-
166-
- run: echo ${{ steps.deploy.outputs.defaultHostName }}
169+
# this shows warnings in the github actions console, because the flag is passed through a validation run,
170+
# but it *is* functional during the actual execution
171+
additionalArguments: --no-wait

.github/workflows/azure-preview-env-destroy.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
timeout-minutes: 5
2525
env:
2626
PR_NUMBER: ${{ github.event.number || github.event.inputs.PR_NUMBER }}
27-
NONPROD_REGISTRY_NAME: ghdocs
2827

2928
steps:
3029
- name: 'Az CLI login'
@@ -37,25 +36,25 @@ jobs:
3736

3837
- name: Get preview app info
3938
env:
40-
FULL_APP_INFO: 1
39+
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
4140
run: .github/actions-scripts/get-preview-app-info.sh
4241

4342
# Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel)
4443
- name: 'Cancel any in progress deployments'
4544
run: |
46-
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ env.RESOURCE_GROUP }} || true
45+
az deployment group cancel --name ${{ env.DEPLOYMENT_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} || true
4746
4847
# Delete web app (which will also delete the App Service plan)
4948
# This will succeed even if the app doesn't exist / has already been deleted
5049
- name: 'Delete App Service App (which will also delete the App Service plan)'
5150
run: |
52-
az webapp delete -n ${{ env.APP_NAME_FULL }} -g ${{ env.RESOURCE_GROUP }}
51+
az container delete -n ${{ env.APP_NAME }} -g ${{ secrets.PREVIEW_ENV_RESOURCE_GROUP }} -y
5352
5453
# Untag all images under this PR's container registry repo - the container registry will automatically remove untagged images.
5554
# This will fail if the IMAGE_REPO doesn't exist, but we don't care
5655
- name: 'Untag all docker images for this PR'
5756
run: |
58-
az acr repository delete -n ${{ env.NONPROD_REGISTRY_NAME }} --repository ${{ env.IMAGE_REPO }} -y || true
57+
az acr repository delete -n ${{ secrets.NONPROD_REGISTRY_NAME }} --repository ${{ env.IMAGE_REPO }} -y || true
5958
6059
# Remove all GitHub deployments from this environment and remove the environment
6160
- uses: strumwolf/delete-deployment-environment@45c821e46baa405e25410700fe2e9643929706a0

.github/workflows/content-changes-table-comment.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ jobs:
4848
env:
4949
PR_NUMBER: ${{ github.event.pull_request.number }}
5050
steps:
51-
- name: 'Az CLI login'
52-
uses: azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf
53-
with:
54-
creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }}
55-
5651
- name: check out repo content
5752
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
5853

5954
- name: Get preview app info
6055
env:
61-
FULL_APP_INFO: 1
56+
APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }}
6257
run: .github/actions-scripts/get-preview-app-info.sh
6358

6459
- name: Setup Node

.github/workflows/prod-build-deploy-azure.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ jobs:
9090
run: |
9191
sed 's|#{IMAGE}#|${{ env.DOCKER_IMAGE }}|g' docker-compose.prod.tmpl.yaml > docker-compose.prod.yaml
9292
93-
- name: 'Apply updated docker-compose.prod.yaml config to preview slot'
93+
- name: 'Apply updated docker-compose.prod.yaml config to staging slot'
9494
run: |
95-
az webapp config container set --multicontainer-config-type COMPOSE --multicontainer-config-file docker-compose.prod.yaml --slot preview -n ghdocs-prod -g docs-prod
95+
az webapp config container set --multicontainer-config-type COMPOSE --multicontainer-config-file docker-compose.prod.yaml --slot staging -n ghdocs-prod -g docs-prod
9696
97-
# Watch preview slot instances to see when all the instances are ready
98-
- name: Check that preview slot is ready
97+
# Watch staging slot instances to see when all the instances are ready
98+
- name: Check that staging slot is ready
9999
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
100100
env:
101101
CHECK_INTERVAL: 10000
@@ -115,7 +115,7 @@ jobs:
115115
let hasStopped = false
116116
const waitDuration = parseInt(process.env.CHECK_INTERVAL, 10) || 10000
117117
async function doCheck() {
118-
const states = getStatesForSlot('preview')
118+
const states = getStatesForSlot('staging')
119119
console.log(`Instance states:`, states)
120120
121121
// We must wait until at-least 1 instance has STOPPED to know we're looking at the "next" deployment and not the "previous" one
@@ -136,10 +136,10 @@ jobs:
136136
137137
doCheck()
138138
139-
# TODO - make a request to verify the preview app version aligns with *this* github action workflow commit sha
140-
- name: 'Swap preview slot to production'
139+
# TODO - make a request to verify the staging app version aligns with *this* github action workflow commit sha
140+
- name: 'Swap staging slot to production'
141141
run: |
142-
az webapp deployment slot swap --slot preview --target-slot production -n ghdocs-prod -g docs-prod
142+
az webapp deployment slot swap --slot staging --target-slot production -n ghdocs-prod -g docs-prod
143143
144144
- name: Purge Fastly edge cache
145145
env:

.github/workflows/test.yml

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,53 @@ 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+
if: ${{ github.repository == 'github/docs-internal' }}
95+
run: |
96+
mv docs-early-access/assets assets/images/early-access
97+
mv docs-early-access/content content/early-access
98+
mv docs-early-access/data data/early-access
99+
rm -r docs-early-access
100+
54101
- name: Checkout LFS objects
55102
run: git lfs checkout
56103

@@ -78,13 +125,6 @@ jobs:
78125
- name: Install dependencies
79126
run: npm ci
80127

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-
88128
- name: Cache nextjs build
89129
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
90130
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ When using the GitHub logos, be sure to follow the [GitHub logo guidelines](http
6060

6161
## Thanks :purple_heart:
6262

63-
Thanks for all your contributions and efforts towards improving the GitHub documentation. We thank you being part of our :sparkles: community :sparkles: !
63+
Thanks for all your contributions and efforts towards improving the GitHub documentation. We thank you being part of our :sparkles: community :sparkles:!
21.8 KB
Loading

0 commit comments

Comments
 (0)