-
Notifications
You must be signed in to change notification settings - Fork 5
104 lines (87 loc) · 3.29 KB
/
sync-authors-on-pr.yml
File metadata and controls
104 lines (87 loc) · 3.29 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
name: Sync Authors Data
on:
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '0 6 * * 1' # Weekly Monday 06:00 UTC
workflow_dispatch:
repository_dispatch:
types: [squad-json-updated]
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm (before setup-node cache)
uses: pnpm/action-setup@v4
with:
version: 10.11.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22.18.0'
cache: 'pnpm'
- name: Install deps
run: pnpm install --frozen-lockfile
- name: Run authors sync (raw URLs)
id: sync
env:
TARGET_SITE: wonderland
USE_RAW_PFP_URLS: 'true'
run: pnpm --filter @handbook/scripts run script:infra:sync-authors
- name: Detect changes (tracked authors.yml only)
id: git_status
run: |
if git diff --quiet -- sites/wonderland/blog/authors.yml; then
echo "changed=0" >> $GITHUB_OUTPUT
else
echo "changed=1" >> $GITHUB_OUTPUT
fi
- name: Commit changes
if: steps.git_status.outputs.changed != '0'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add sites/wonderland/blog/authors.yml || true
git commit -m "chore(ci): sync authors from squad.json" || true
- name: Push changes to PR branch
if: steps.git_status.outputs.changed != '0' && github.event_name == 'pull_request'
run: |
git push
- name: Create branch and push (scheduled/dispatch)
if: steps.git_status.outputs.changed != '0' && github.event_name != 'pull_request'
env:
BRANCH_NAME: sync/authors-${{ github.run_id }}
run: |
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
- name: Create PR (scheduled/dispatch)
if: steps.git_status.outputs.changed != '0' && github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'chore(ci): sync authors from squad.json'
title: "chore: sync authors from squad.json"
body: |
Automated sync from `defi-wonderland/web` squad.json.
- Adds/updates authors in `sites/wonderland/blog/authors.yml`
- Downloads profile images to `sites/wonderland/static/img/pfp`
See job summary for details.
labels: 'automated, authors-sync'
branch: ${{ env.BRANCH_NAME }}
base: ${{ github.event.repository.default_branch || 'main' }}
- name: Comment summary on PR
if: github.event_name == 'pull_request'
run: |
if [ -f AUTHORS_SYNC_SUMMARY.md ]; then
gh pr comment ${{ github.event.pull_request.number }} --body-file AUTHORS_SYNC_SUMMARY.md
else
gh pr comment ${{ github.event.pull_request.number }} --body "Automated authors sync ran. See the job summary for details."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}