fix: update plug #42
Workflow file for this run
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: Update Tenant DB Catalog | |
| on: | |
| pull_request: | |
| paths: | |
| - "lib/realtime/tenants/repo/migrations/**" | |
| - "lib/realtime/tenants/migrations.ex" | |
| - "lib/mix/tasks/realtime.export_tenant_db_catalog.ex" | |
| - "priv/repo/tenant_db_catalog_*.json" | |
| - "mix.lock" | |
| - "mise.toml" | |
| - "compose.dbs.yml" | |
| - ".github/workflows/update-tenant-db-catalog.yml" | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| env: | |
| POSTGRES_IMAGE: supabase/postgres:17.6.1.127 | |
| jobs: | |
| update-tenant-db-catalog: | |
| name: Maybe regenerate tenant catalog | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| if: github.event.pull_request.head.repo.full_name == github.repository | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | |
| with: | |
| client-id: ${{ secrets.GH_APP_MANAGER_ID }} | |
| private-key: ${{ secrets.GH_APP_MANAGER_PRIVATE_KEY }} | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Setup mise | |
| uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1 | |
| - name: Cache Mix | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: ${{ github.workflow }}-${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
| restore-keys: | | |
| ${{ github.workflow }}-${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Cache Docker images | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| id: docker-cache | |
| with: | |
| path: /tmp/docker-images | |
| key: docker-images-zstd-${{ env.POSTGRES_IMAGE }} | |
| - name: Load Docker images from cache | |
| if: steps.docker-cache.outputs.cache-hit == 'true' | |
| run: zstd -d --stdout /tmp/docker-images/postgres.tar.zst | docker image load | |
| - name: Pull and save Docker images | |
| if: steps.docker-cache.outputs.cache-hit != 'true' | |
| run: | | |
| docker pull ${{ env.POSTGRES_IMAGE }} | |
| mkdir -p /tmp/docker-images | |
| docker image save ${{ env.POSTGRES_IMAGE }} | zstd -T0 -o /tmp/docker-images/postgres.tar.zst | |
| - name: Start Postgres | |
| run: docker compose -f compose.dbs.yml up -d --wait | |
| - name: Set up realtime DB and migrate tenant DB | |
| run: mix ecto.setup | |
| - name: Export catalog snapshot | |
| run: mix realtime.export_tenant_db_catalog | |
| - name: Check if catalog changed | |
| id: check-changes | |
| run: | | |
| git add priv/repo/tenant_db_catalog_17.json | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push catalog | |
| if: steps.check-changes.outputs.changed == 'true' | |
| env: | |
| PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git commit -m "chore: update tenant_db_catalog_17.json" | |
| git push origin "HEAD:$PR_HEAD_REF" |