-
Notifications
You must be signed in to change notification settings - Fork 5
80 lines (67 loc) · 2.82 KB
/
Copy pathsync-libraries.yml
File metadata and controls
80 lines (67 loc) · 2.82 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
name: Sync filament libraries
on:
schedule:
# Daily at 04:17 UTC. Off-peak avoids the top-of-hour cron stampede on
# GitHub's runners and keeps the sync from racing the deploy job.
- cron: '17 4 * * *'
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
# SYNC_BOT_TOKEN is an admin PAT (ondrejbartas). Used here so the PR
# creator and merger has the admin identity, letting `gh pr merge --admin`
# bypass the CODEOWNERS-approval requirement (enforce_admins: false).
- uses: actions/checkout@v4
with:
token: ${{ secrets.SYNC_BOT_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- name: Sync OpenPrintTag library
run: npm run sync:openprinttag
- name: Sync HueForge library
run: npm run sync:hueforge
- name: Compute commit message
id: msg
run: |
OPT='data/filament-library-openprinttag.json'
HF='data/filament-library-hueforge.json'
OPT_COUNT=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$OPT','utf8')).entryCount)")
HF_COUNT=$(node -e "console.log(JSON.parse(require('fs').readFileSync('$HF','utf8')).entryCount)")
DATE=$(date -u +%Y-%m-%d)
echo "msg=chore: refresh filament libraries (OpenPrintTag ${OPT_COUNT}, HueForge ${HF_COUNT}, ${DATE})" >> "$GITHUB_OUTPUT"
- name: Open PR if changed
id: pr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.SYNC_BOT_TOKEN }}
commit-message: ${{ steps.msg.outputs.msg }}
title: ${{ steps.msg.outputs.msg }}
body: |
Automated daily refresh of filament libraries.
- OpenPrintTag → `data/filament-library-openprinttag.json`
- HueForge → `data/filament-library-hueforge.json`
Source workflow: [`sync-libraries.yml`](./.github/workflows/sync-libraries.yml).
Squash-merged automatically by the workflow using the admin PAT
(`SYNC_BOT_TOKEN`) — `enforce_admins: false` allows this bypass.
branch: bot/sync-libraries
delete-branch: true
author: 'filament-library-bot <[email protected]>'
committer: 'filament-library-bot <[email protected]>'
add-paths: |
data/filament-library-openprinttag.json
data/filament-library-hueforge.json
- name: Squash-merge as admin
if: steps.pr.outputs.pull-request-number
run: |
gh pr merge "${{ steps.pr.outputs.pull-request-number }}" \
--admin --squash --delete-branch \
--repo "${{ github.repository }}"
env:
GH_TOKEN: ${{ secrets.SYNC_BOT_TOKEN }}