|
| 1 | +name: Sync Script Tags to Website |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + paths: |
| 7 | + - 'scripts-metadata.yaml' |
| 8 | + workflow_dispatch: # Allow manual trigger |
| 9 | + |
| 10 | +jobs: |
| 11 | + sync-tags: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout msp-scripts repo |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + path: msp-scripts |
| 19 | + |
| 20 | + - name: Checkout website repo |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + repository: Glyph-SH/website |
| 24 | + token: ${{ secrets.WEBSITE_PAT }} |
| 25 | + path: website |
| 26 | + ref: develop # Always update develop branch |
| 27 | + |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: '3.x' |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: pip install PyYAML |
| 35 | + |
| 36 | + - name: Run sync script |
| 37 | + run: | |
| 38 | + cd msp-scripts |
| 39 | + python3 sync-tags-to-website.py ../website |
| 40 | +
|
| 41 | + - name: Check for changes |
| 42 | + id: check_changes |
| 43 | + run: | |
| 44 | + cd website |
| 45 | + if [[ -n $(git status --porcelain) ]]; then |
| 46 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 47 | + else |
| 48 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 49 | + fi |
| 50 | +
|
| 51 | + - name: Commit and push changes |
| 52 | + if: steps.check_changes.outputs.has_changes == 'true' |
| 53 | + run: | |
| 54 | + cd website |
| 55 | + git config user.name "GitHub Actions Bot" |
| 56 | + git config user.email "actions@github.com" |
| 57 | + git add content/scripts/ |
| 58 | + git commit -m "chore(scripts): auto-sync tags from msp-scripts metadata |
| 59 | +
|
| 60 | +Synced by GitHub Actions from msp-scripts@${{ github.sha }}" |
| 61 | + git push origin develop |
| 62 | + |
| 63 | + - name: Summary |
| 64 | + run: | |
| 65 | + if [ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]; then |
| 66 | + echo "✅ Tags synced successfully to website repo" |
| 67 | + else |
| 68 | + echo "⏭️ No changes detected - tags already in sync" |
| 69 | + fi |
0 commit comments