Skip to content

Commit 42a3cf7

Browse files
authored
Merge pull request #23580 from github/repo-sync
repo sync
2 parents 1101553 + e2dc421 commit 42a3cf7

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env node
2+
import got from 'got'
3+
4+
import { setOutput } from '@actions/core'
5+
6+
import github from '../../script/helpers/github.js'
7+
import { getActionContext } from './lib/action-context.js'
8+
9+
async function main() {
10+
const sha = await getBuiltSHA()
11+
console.log({ sha })
12+
13+
const actionContext = getActionContext()
14+
const { owner, repo } = actionContext
15+
16+
const octokit = github()
17+
let number = ''
18+
19+
const q = `${sha} repo:"${owner}/${repo}"`
20+
const { data } = await octokit.rest.search.issuesAndPullRequests({ q })
21+
for (const issue of data.items) {
22+
// console.log(issue)
23+
console.log('ID:', issue.id)
24+
console.log('Number:', issue.number)
25+
console.log('URL:', issue.html_url)
26+
number = issue.number
27+
if (number) {
28+
break
29+
}
30+
}
31+
32+
setOutput('number', number)
33+
}
34+
35+
async function getBuiltSHA() {
36+
const r = await got('https://docs.github.com/_build')
37+
const sha = r.body.trim()
38+
if (!/[a-f0-9]{40}/.test(sha)) {
39+
throw new Error(`Response body does not look like a SHA ('${r.body.slice(0, 100)}'...)`)
40+
}
41+
return sha
42+
}
43+
44+
main()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Notify about production deployment
2+
3+
# **What it does**: Posts a comment on the PR whose merge got into production.
4+
# **Why we have it**: So that the PR author can be informed when their merged PR is in production.
5+
# **Who does it impact**: Writers
6+
7+
on:
8+
workflow_dispatch:
9+
workflow_run:
10+
# Note, we could do this after the "Purge Fastly" finished
11+
workflows: ['Azure Production - Build and Deploy']
12+
types:
13+
- completed
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
jobs:
20+
find-pr-and-post-comment:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check out repo
24+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
25+
26+
- uses: ./.github/actions/node-npm-setup
27+
28+
# The "Purge Fastly" action takes about 6 minutes to purge all
29+
# languages. First does the language agnostic URLs, then English,
30+
# then all the other languages.
31+
# So it takes about ~30 seconds until it has sent the purge for
32+
# all English docs.
33+
- name: Sleep a little to give Fastly Purge a chance
34+
run: sleep 30
35+
36+
- name: Find last PR
37+
id: get-number
38+
timeout-minutes: 3
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}
41+
run: .github/actions-scripts/find-past-built-pr.js
42+
43+
- name: Find content directory changes comment
44+
if: ${{ steps.get-number.outputs.number != '' }}
45+
uses: peter-evans/find-comment@f4499a714d59013c74a08789b48abe4b704364a0
46+
id: findComment
47+
with:
48+
issue-number: ${{ steps.get-number.outputs.number }}
49+
comment-author: 'github-actions[bot]'
50+
body-includes: '<!-- GONE_TO_PRODUCTION -->'
51+
52+
- name: Update comment
53+
if: ${{ steps.get-number.outputs.number != '' }}
54+
uses: peter-evans/create-or-update-comment@c9fcb64660bc90ec1cc535646af190c992007c32
55+
with:
56+
comment-id: ${{ steps.findComment.outputs.comment-id }}
57+
issue-number: ${{ steps.get-number.outputs.number }}
58+
body: |
59+
<!-- GONE_TO_PRODUCTION -->
60+
🚀 **This pull request has gone into production!**
61+
62+
The SHA of https://docs.github.com/_build matches the merge commit in this PR.
63+
edit-mode: replace

0 commit comments

Comments
 (0)