Nightly stack sync #19
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: Nightly stack sync | |
| on: | |
| schedule: | |
| # Run every night at 02:00 UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync: | |
| name: Regenerate stacks and open PR if drifted | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout dev branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: dev | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Python deps | |
| run: pip install -r tools/requirements.txt | |
| - name: Install yq | |
| run: | | |
| YQ_VERSION="v4.44.3" | |
| sudo wget -qO /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" | |
| sudo chmod +x /usr/local/bin/yq | |
| yq --version | |
| - name: Validate YAML with yq | |
| run: | | |
| set -euo pipefail | |
| while IFS= read -r file; do | |
| yq e '.' "$file" >/dev/null | |
| done < <(find .github/workflows stacks -type f \( -name '*.yml' -o -name '*.yaml' \) | sort) | |
| - name: Regenerate stacks | |
| run: python3 tools/generate_stacks.py | |
| - name: Check for drift | |
| id: drift | |
| run: | | |
| if git diff --quiet stacks/; then | |
| echo "drifted=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "drifted=true" >> "$GITHUB_OUTPUT" | |
| git diff --stat stacks/ | |
| fi | |
| - name: Open or update PR for drifted stacks | |
| if: steps.drift.outputs.drifted == 'true' | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| signoff: true | |
| delete-branch: true | |
| commit-message: "chore(stacks): nightly regeneration from compose sources" | |
| author: "Author <actions@github.com>" | |
| title: "chore(stacks): nightly stack regeneration" | |
| body: | | |
| Automated PR: stacks/ drifted from compose sources. Generated by the nightly-stack-sync workflow. | |
| Run `./stackctl.sh sync` locally to reproduce the diff. | |
| branch: chore/nightly-stack-sync | |
| labels: ":skateboard: skip-changelog" | |
| assignees: "wax911" | |
| reviewers: "wax911" |