Repository navigation
91 lines (80 loc) · 2.76 KB
/
Copy pathsync-submodules.yml
File metadata and controls
91 lines (80 loc) · 2.76 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
name: Sync Submodule Pointers
on:
repository_dispatch:
types: [submodule-sync]
workflow_dispatch:
inputs:
source_repo:
description: Source repo name (highda/chords-trainer or highda/glitch-lab)
required: true
type: choice
options:
- highda/chords-trainer
- highda/glitch-lab
permissions:
contents: write
concurrency:
group: submodule-sync-main
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Resolve source repo
id: source
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_REPO: ${{ inputs.source_repo }}
PAYLOAD_REPO: ${{ github.event.client_payload.source_repo }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
repo="$INPUT_REPO"
else
repo="$PAYLOAD_REPO"
fi
# Only allow known repos; rejects anything that could reach later steps.
case "$repo" in
highda/chords-trainer|highda/glitch-lab) echo "repo=$repo" >> "$GITHUB_OUTPUT" ;;
*) echo "Unsupported source repo: $repo"; exit 1 ;;
esac
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PAGES_SYNC_TOKEN }}
submodules: recursive
- name: Select submodule path
id: submodule
env:
REPO: ${{ steps.source.outputs.repo }}
run: |
case "$REPO" in
"highda/chords-trainer") echo "path=vibecode-snippets/chords-trainer" >> "$GITHUB_OUTPUT" ;;
"highda/glitch-lab") echo "path=vibecode-snippets/glitch-lab" >> "$GITHUB_OUTPUT" ;;
*)
echo "Unsupported source repo: $REPO"
exit 1
;;
esac
- name: Sync selected submodule to latest main
run: |
git submodule sync -- "${{ steps.submodule.outputs.path }}"
git submodule update --init --remote -- "${{ steps.submodule.outputs.path }}"
- name: Commit and push pointer update
run: |
if git diff --quiet -- "${{ steps.submodule.outputs.path }}"; then
echo "No submodule pointer change."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add "${{ steps.submodule.outputs.path }}"
git commit -m "Update ${{ steps.submodule.outputs.path }} submodule pointer"
for attempt in 1 2 3; do
if git push origin main; then
exit 0
fi
git fetch origin main
git rebase origin/main
done
echo "Failed to push submodule pointer after retries."
exit 1