Registry index from tags #2103
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: Registry index from tags | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "*/30 * * * *" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: registry-index-from-tags | |
| cancel-in-progress: true | |
| jobs: | |
| build-index: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Generate versions from tags | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| python .github/scripts/index_from_tags.py | |
| - name: Create or update PR and try auto-merge if changes | |
| env: | |
| GH_TOKEN: ${{ secrets.REGISTRY_BOT_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if git diff --quiet; then | |
| echo "No changes" | |
| exit 0 | |
| fi | |
| BRANCH="bot/registry-index-from-tags" | |
| git switch -C "$BRANCH" | |
| git add index/*.json | |
| git commit -m "registry: update versions from tags" || true | |
| git push -u origin "$BRANCH" --force | |
| PR_URL="$( | |
| gh pr list \ | |
| --repo "${{ github.repository }}" \ | |
| --head "$BRANCH" \ | |
| --state open \ | |
| --json url \ | |
| -q '.[0].url' \ | |
| || true | |
| )" | |
| if [ -n "${PR_URL}" ]; then | |
| echo "OPEN PR exists: ${PR_URL}" | |
| else | |
| PR_URL="$( | |
| gh pr create \ | |
| --repo "${{ github.repository }}" \ | |
| --base main \ | |
| --head "$BRANCH" \ | |
| --title "registry: update versions from tags" \ | |
| --body "Automated update of index versions from Git tags." \ | |
| | tail -n 1 | |
| )" | |
| echo "PR created: ${PR_URL}" | |
| fi | |
| if gh pr merge "$PR_URL" --repo "${{ github.repository }}" --squash --auto >/dev/null 2>&1; then | |
| echo "Auto-merge enabled for: ${PR_URL}" | |
| else | |
| echo "Could not enable auto-merge automatically." | |
| echo "PR pending manual merge: ${PR_URL}" | |
| fi |