Merge pull request #51 from suyar/dependabot/docker_compose/dependabo… #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Sync Workflow Versions | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'dependabot/**/docker-compose.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: auto-sync-workflow-versions-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # PAT with `workflow` scope so the later `git push` can update files | |
| # under .github/workflows/ (default GITHUB_TOKEN cannot). | |
| token: ${{ secrets.WORKFLOW_PAT }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.x' | |
| - name: Sync versions from changed compose files | |
| run: | | |
| CHANGED_FILES="$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'dependabot/**/docker-compose.yml' || true)" | |
| if [ -z "$CHANGED_FILES" ]; then | |
| echo "No changed dependabot compose files in this push." | |
| exit 0 | |
| fi | |
| python scripts/sync_workflow_versions.py $CHANGED_FILES | |
| - name: Collect updated workflow files | |
| id: collect | |
| run: | | |
| UPDATED="$(git diff --name-only -- '.github/workflows/sync-*.yml' | tr '\n' ' ')" | |
| echo "updated=$UPDATED" >> "$GITHUB_OUTPUT" | |
| if [ -z "$UPDATED" ]; then | |
| echo "No workflow version changes." | |
| else | |
| echo "Updated workflows: $UPDATED" | |
| fi | |
| - name: Commit and push if changed | |
| if: steps.collect.outputs.updated != '' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add .github/workflows/sync-*.yml | |
| git commit -m "chore: sync workflow matrix versions from dependabot compose" | |
| git push |