Region Discovery #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: Region Discovery | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pages: write | |
| pull-requests: write | |
| concurrency: | |
| group: region-discovery | |
| cancel-in-progress: false | |
| jobs: | |
| discover: | |
| runs-on: ubuntu-latest | |
| environment: region-discovery | |
| outputs: | |
| data_changed: ${{ steps.commit.outputs.data_changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Azure Login (OIDC) | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Verify Azure session | |
| run: az account show --query "{subscription:name, id:id}" -o table | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install dependencies | |
| working-directory: scripts/region-discovery | |
| run: uv sync | |
| - name: Run discovery | |
| working-directory: scripts/region-discovery | |
| run: | | |
| uv run python discover.py \ | |
| --subscription-id "${{ secrets.AZURE_SUBSCRIPTION_ID }}" \ | |
| --output-format json \ | |
| --output-dir ../../aca-getting-started/data | |
| - name: Commit and push updated data | |
| id: commit | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add aca-getting-started/data/region-features.json | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| echo "data_changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| BRANCH="auto/region-data-update" | |
| git checkout -b "$BRANCH" | |
| git commit -m "chore: update region availability data | |
| Automated daily refresh of ACA region feature matrix. | |
| Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | |
| git push --force origin "$BRANCH" | |
| echo "data_changed=true" >> "$GITHUB_OUTPUT" | |
| # Create PR if one doesn't already exist (best-effort) | |
| EXISTING_PR=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number' || true) | |
| if [ -z "$EXISTING_PR" ]; then | |
| gh pr create \ | |
| --title "chore: update region availability data" \ | |
| --body "Automated daily refresh of ACA region feature matrix." \ | |
| --head "$BRANCH" \ | |
| --base main || echo "::warning::Could not create PR automatically. Please create one from branch $BRANCH." | |
| else | |
| echo "PR #$EXISTING_PR already exists" | |
| fi | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| deploy-pages: | |
| needs: discover | |
| if: needs.discover.outputs.data_changed == 'true' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout latest main | |
| 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: '.' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |