-
Notifications
You must be signed in to change notification settings - Fork 17
78 lines (66 loc) · 2.46 KB
/
Copy pathschema-sync.yml
File metadata and controls
78 lines (66 loc) · 2.46 KB
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
name: Daily schema sync
on:
schedule:
# Daily at 08:30 UTC
- cron: "30 8 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: schema-sync
cancel-in-progress: true
jobs:
sync:
# Don't run in forks
if: github.repository == 'mozilla/enterprise-admin-reference'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: ".nvmrc"
cache: npm
- name: Install
run: npm ci
- name: Sync schema from upstream
run: npm run schema:sync
# Note this PR won't trigger `./pull-requests.yml` builds yet
- name: Open PR on drift
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ -z "$(git status --porcelain schema/policies-schema.json)" ]; then
echo "No schema changes to commit."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}"
git switch -C automation/schema-sync
git add schema/
git commit -m "chore(schema): sync from upstream"
git push --force origin automation/schema-sync
pr_number=$(
gh pr list \
--head automation/schema-sync \
--base main \
--state open \
--json number \
--jq '.[0].number'
)
if [ -n "$pr_number" ]; then
echo "Updated existing schema-sync PR #${pr_number}."
else
gh pr create \
--title "chore(schema): sync from upstream" \
--body "Automated daily sync of \`schema/policies-schema.json\`.
Review the diff for new, removed, or changed policies before merging. A new policy here usually needs a matching entry in \`release-notes/firefox.md\`.
_Opened by the [\`.github/workflows/schema-sync.yml\`](https://github.com/${{ github.repository }}/tree/main/.github/workflows/schema-sync.yml) workflow._" \
--label schema-sync \
--label "automated pr"
fi