-
Notifications
You must be signed in to change notification settings - Fork 113
92 lines (82 loc) · 2.92 KB
/
fetch-related-content.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Fetch related pages from Swiftype
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # start of every day
env:
BOT_NAME: svc-docs-eng-opensource-bot
BOT_EMAIL: svc-docs-eng-opensource-bot@newrelic.com
jobs:
fetch-swiftype-results:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: main
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Gatsby Build
run: yarn run build:related-content
- name: Temporarily disable branch protection
id: disable-branch-protection
uses: actions/github-script@v6
with:
github-token: ${{ secrets.DOCS_ENG_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.rest.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: null,
restrictions: null,
enforce_admins: null,
required_pull_request_reviews: null
})
console.log("Result:", result)
- name: Commit changes
id: commit-changes
run: |
git config --local user.email "${{ env.BOT_EMAIL }}"
git config --local user.name "${{ env.BOT_NAME }}"
git add ./src/data/related-pages.json
git commit -m 'chore(related-content): updated related content data'
echo "commit=true" >> $GITHUB_OUTPUT
# Push directly to `main` branch because we want updates to the related
# content to trigger a deploy. If we commit directly to the `develop`
# branch, it would require a PR from the team to deploy the changes.
- name: Push Commit
if: steps.commit-changes.outputs.commit == 'true'
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.DOCS_ENG_BOT_TOKEN }}
branch: main
- name: Re-enable branch protection
id: enable-branch-protection
if: always()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.DOCS_ENG_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.rest.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: {
strict: false,
contexts: [
'Gatsby Build Service - developer-website'
]
},
restrictions: null,
enforce_admins: true,
required_pull_request_reviews: null
})
console.log("Result:", result)