|
| 1 | +name: Sync Submodule Pointers |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [submodule-sync] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + source_repo: |
| 9 | + description: Source repo name (highda/chords-trainer or highda/glitch-lab) |
| 10 | + required: true |
| 11 | + type: choice |
| 12 | + options: |
| 13 | + - highda/chords-trainer |
| 14 | + - highda/glitch-lab |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + sync: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Resolve source repo |
| 24 | + id: source |
| 25 | + run: | |
| 26 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 27 | + echo "repo=${{ inputs.source_repo }}" >> "$GITHUB_OUTPUT" |
| 28 | + else |
| 29 | + echo "repo=${{ github.event.client_payload.source_repo }}" >> "$GITHUB_OUTPUT" |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v6 |
| 34 | + with: |
| 35 | + token: ${{ secrets.PAGES_SYNC_TOKEN }} |
| 36 | + submodules: recursive |
| 37 | + |
| 38 | + - name: Select submodule path |
| 39 | + id: submodule |
| 40 | + run: | |
| 41 | + case "${{ steps.source.outputs.repo }}" in |
| 42 | + "highda/chords-trainer") echo "path=vibecode-snippets/chords-trainer" >> "$GITHUB_OUTPUT" ;; |
| 43 | + "highda/glitch-lab") echo "path=vibecode-snippets/glitch-lab" >> "$GITHUB_OUTPUT" ;; |
| 44 | + *) |
| 45 | + echo "Unsupported source repo: ${{ steps.source.outputs.repo }}" |
| 46 | + exit 1 |
| 47 | + ;; |
| 48 | + esac |
| 49 | +
|
| 50 | + - name: Sync selected submodule to latest main |
| 51 | + run: | |
| 52 | + git submodule sync -- "${{ steps.submodule.outputs.path }}" |
| 53 | + git submodule update --init --remote -- "${{ steps.submodule.outputs.path }}" |
| 54 | +
|
| 55 | + - name: Commit and push pointer update |
| 56 | + run: | |
| 57 | + if git diff --quiet -- "${{ steps.submodule.outputs.path }}"; then |
| 58 | + echo "No submodule pointer change." |
| 59 | + exit 0 |
| 60 | + fi |
| 61 | +
|
| 62 | + git config user.name "github-actions[bot]" |
| 63 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 64 | + git add "${{ steps.submodule.outputs.path }}" |
| 65 | + git commit -m "Update ${{ steps.submodule.outputs.path }} submodule pointer" |
| 66 | + git push origin main |
0 commit comments