Repository navigation
107 lines (93 loc) · 4.07 KB
/
Copy pathsync-spec.yml
File metadata and controls
107 lines (93 loc) · 4.07 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Sync spec — notice a new specification release and open a pull request.
#
# The site vendors the normative documents (see sync.mjs), which means a release
# upstream does not reach the site until someone pulls it in. This watches for
# that and does the pulling, but stops at a pull request: a human still reads
# the diff before it publishes, and the build itself never touches the network.
#
name: Sync spec
on:
schedule:
# Daily. Off the hour, because top-of-hour cron slots are the congested ones.
- cron: "17 6 * * *"
workflow_dispatch:
inputs:
ref:
description: "Tag or branch to sync (default: the latest upstream release)"
required: false
type: string
permissions:
contents: write
pull-requests: write
concurrency:
group: sync-spec
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Decide what to sync
id: target
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_REF: ${{ inputs.ref }}
run: |
set -euo pipefail
ref="$INPUT_REF"
if [ -z "$ref" ]; then
ref=$(gh release view --repo OpenPredicate/open-predicate --json tagName -q .tagName)
fi
# What the site currently claims, as recorded by the last sync.
have="v$(jq -r .release content/spec-version.json)"
echo "ref=$ref" >> "$GITHUB_OUTPUT"
if [ "$ref" = "$have" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "::notice::Already synced to $have. Nothing to do."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "::notice::Upstream is $ref, the site is on $have."
fi
- name: Install
if: steps.target.outputs.changed == 'true'
run: npm ci
- name: Sync
if: steps.target.outputs.changed == 'true'
run: node sync.mjs "${{ steps.target.outputs.ref }}"
# ci.yml also runs these on the pull request. Running them here too is
# not redundant: it must not gate the PR being *opened*, because a sync
# that fails its tests is exactly the case a human most needs to see the
# diff for. So the result is recorded and reported in the body instead.
- name: Build and test
if: steps.target.outputs.changed == 'true'
id: verify
continue-on-error: true
run: npm test
- name: Open a pull request
if: steps.target.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
branch: sync/spec-${{ steps.target.outputs.ref }}
delete-branch: true
title: "Sync the vendored spec to ${{ steps.target.outputs.ref }}"
commit-message: "Sync the vendored spec to ${{ steps.target.outputs.ref }}"
labels: spec-sync
body: |
[`${{ steps.target.outputs.ref }}`](https://github.com/OpenPredicate/open-predicate/releases/tag/${{ steps.target.outputs.ref }})
was released upstream. This is `node sync.mjs ${{ steps.target.outputs.ref }}`, nothing
else — the version numbers the site displays are derived from the artefacts in this
diff, not typed, so there is no constant to bump by hand.
**`npm test`: ${{ steps.verify.outcome == 'success' && 'passed ✅' || 'FAILED ❌' }}**
([log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}))
Worth a look before merging:
- `content/spec-version.json` — the recorded release and grammar versions.
- Whether the grammar moved. If `static/schema/` gained a directory, the `$id` changed
and consumers pinning the old one need to know; the old file stays served, and
`/schema/` picks up the new row on its own.
- The rendered diff on `/spec/` and `/changelog/`, via `npm start`.
Opened by [`sync-spec.yml`](.github/workflows/sync-spec.yml).