Skip to content

Commit 42e9a5c

Browse files
authored
Add GitHub actions to resync (#2950)
1 parent 2e0d76b commit 42e9a5c

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Configlet Auto Sync
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 15 * *'
7+
8+
jobs:
9+
sync-docs-metadata:
10+
timeout-minutes: 10
11+
runs-on: ubuntu-24.04
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Fetch configlet
18+
run: ./bin/fetch-configlet
19+
20+
- name: Run configlet sync for files
21+
run: ./bin/configlet sync --docs --metadata --filepaths -u -y
22+
23+
- name: Create pull request if changes
24+
uses: peter-evans/create-pull-request@v5
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
commit-message: "🤖 Auto-sync docs, metadata, and filepaths"
28+
title: "🤖 Configlet sync: docs, metadata, and filepaths"
29+
body: |
30+
This PR was generated automatically by a scheduled workflow.
31+
32+
It includes updates from `configlet sync` for:
33+
- 📄 Documentation
34+
- 🧭 Metadata
35+
- 🗂️ Filepaths
36+
37+
Please review and merge if everything looks good!
38+
branch: configlet-auto-sync
39+
delete-branch: true
40+
41+
check-test-sync:
42+
timeout-minutes: 10
43+
runs-on: ubuntu-24.04
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
- name: Fetch configlet
50+
run: ./bin/fetch-configlet
51+
52+
- name: Run configlet sync for test and capture output
53+
id: sync_test
54+
run: |
55+
configlet_raw_output="$(./bin/configlet sync --tests | tee .github/sync-test-output.txt)"
56+
57+
echo "configlet output:"
58+
echo "$configlet_raw_output"
59+
60+
echo '```' > .github/sync-test-output.txt
61+
echo "$configlet_raw_output" >> .github/sync-test-output.txt
62+
echo '```' >> .github/sync-test-output.txt
63+
64+
echo "output<<EOF" >> "$GITHUB_OUTPUT"
65+
echo "$configlet_raw_output" >> "$GITHUB_OUTPUT"
66+
echo "EOF" >> "$GITHUB_OUTPUT"
67+
68+
- name: Find existing issue for test sync
69+
id: find_issue
70+
if: ${{ !contains(steps.sync_test.outputs.output, 'Every exercise has up-to-date tests!') }}
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
run: |
74+
ISSUE_TITLE="🚨 configlet sync --test found unsynced tests"
75+
ISSUE_DATA=$(gh issue list --search "is:issue is:open in:title \"${ISSUE_TITLE}\" repo:${{ github.repository }}" --json number,title --jq '.[0]')
76+
77+
if [ -z "$ISSUE_DATA" ]; then
78+
echo "No open issue found with title: '${ISSUE_TITLE}'. A new one will be created."
79+
echo "issue_number=" >> $GITHUB_OUTPUT
80+
else
81+
ISSUE_NUMBER=$(echo "$ISSUE_DATA" | jq -r '.number')
82+
echo "Found existing issue number: $ISSUE_NUMBER for title: '$ISSUE_TITLE'"
83+
echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
84+
fi
85+
86+
- name: Create or Update issue if tests are not synced
87+
if: ${{ !contains(steps.sync_test.outputs.output, 'Every exercise has up-to-date tests!') }}
88+
uses: peter-evans/create-issue-from-file@v5
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
title: "🚨 configlet sync --test found unsynced tests"
92+
content-filepath: .github/sync-test-output.txt
93+
issue-number: ${{ steps.find_issue.outputs.issue_number || '' }}

0 commit comments

Comments
 (0)