name: Update Documentation on: push: branches: - main paths: - 'Casks/**' - 'Formula/**' - '.github/workflows/docs.yml' - 'scripts/generate-docs.sh' workflow_dispatch: permissions: contents: write pages: write id-token: write concurrency: group: update-docs cancel-in-progress: false jobs: update-docs: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Generate documentation run: | chmod +x scripts/generate-docs.sh ./scripts/generate-docs.sh - name: Check for changes id: check-changes run: | if git diff --quiet docs/index.html; then echo "changed=false" >> "$GITHUB_OUTPUT" else echo "changed=true" >> "$GITHUB_OUTPUT" fi - name: Commit and push changes if: steps.check-changes.outputs.changed == 'true' run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add docs/ git commit -m "docs: auto-update documentation from casks" for attempt in 1 2 3 4; do if git pull --rebase origin main; then git push && exit 0 else git rebase --abort || true git reset --hard origin/main ./scripts/generate-docs.sh git diff --quiet docs/index.html && exit 0 git add docs/ git commit -m "docs: auto-update documentation from casks" git push && exit 0 fi sleep $((attempt * 5)) done echo "could not push after 4 attempts" >&2 exit 1 deploy-pages: needs: update-docs runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Checkout uses: actions/checkout@v4 with: ref: main - name: Setup Pages uses: actions/configure-pages@v4 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: 'docs' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4