Skip to content

Commit 1a5b90e

Browse files
lennessyyclaudeflippedcoder
authored
ci: Add daily snipsync GitHub workflow (#4324)
* Add daily snipsync GitHub workflow Automates code snippet syncing from source repos on a daily schedule, creating or updating a single PR with any changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * temp: add push trigger to snipsync workflow for testing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Update .github/workflows/snipsync.yml Co-authored-by: Milecia McG <47196133+flippedcoder@users.noreply.github.com> * Remove temporary push trigger from snipsync workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Milecia McG <47196133+flippedcoder@users.noreply.github.com>
1 parent a189b35 commit 1a5b90e

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/snipsync.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Snipsync
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # Daily at 6:00 UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
snipsync:
10+
name: Sync code snippets
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
- name: Generate token
17+
id: generate_token
18+
uses: actions/create-github-app-token@v1
19+
with:
20+
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
21+
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
22+
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
with:
26+
token: ${{ steps.generate_token.outputs.token }}
27+
ref: main
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: yarn
34+
35+
- name: Install dependencies
36+
run: yarn install --frozen-lockfile
37+
38+
- name: Run snipsync
39+
run: yarn snipsync
40+
41+
- name: Check for changes
42+
id: changes
43+
run: |
44+
if git diff --quiet; then
45+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
- name: Commit and push changes
51+
if: steps.changes.outputs.has_changes == 'true'
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
56+
branch_name="snipsync/daily-update"
57+
git checkout -B "$branch_name"
58+
git add docs/
59+
git commit -m "chore: sync code snippets via snipsync"
60+
git push --force-with-lease origin "$branch_name"
61+
62+
- name: Create or update PR
63+
if: steps.changes.outputs.has_changes == 'true'
64+
env:
65+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
66+
run: |
67+
branch_name="snipsync/daily-update"
68+
existing_pr=$(gh pr list --head "$branch_name" --state open --json number --jq '.[0].number')
69+
70+
if [ -n "$existing_pr" ]; then
71+
echo "PR #$existing_pr already exists — updated with latest push."
72+
else
73+
gh pr create \
74+
--title "chore: sync code snippets" \
75+
--body "$(cat <<'EOF'
76+
Automated daily sync of code snippets from source repositories via snipsync.
77+
78+
This PR was generated by the [Snipsync workflow](https://github.com/${{ github.repository }}/actions/workflows/snipsync.yml).
79+
EOF
80+
)" \
81+
--head "$branch_name" \
82+
--base "main"
83+
fi

0 commit comments

Comments
 (0)