Don't send community event invites to users already attending #2963
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: Auto-format | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| detect-changes: | |
| name: Detect changes | |
| runs-on: ubuntu-latest | |
| if: github.actor != 'dependabot[bot]' | |
| outputs: | |
| backend: ${{ steps.filter.outputs.backend }} | |
| frontend: ${{ steps.filter.outputs.frontend }} | |
| mobile: ${{ steps.filter.outputs.mobile }} | |
| models: ${{ steps.filter.outputs.models }} | |
| migrations: ${{ steps.filter.outputs.migrations }} | |
| templates: ${{ steps.filter.outputs.templates }} | |
| any: ${{ steps.filter.outputs.changes != '[]' }} | |
| steps: | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| backend: | |
| - 'app/backend/**' | |
| frontend: | |
| - 'app/web/**' | |
| mobile: | |
| - 'app/mobile/**' | |
| models: | |
| - 'app/backend/src/couchers/models/**' | |
| migrations: | |
| - 'app/backend/src/couchers/migrations/versions/**' | |
| templates: | |
| - 'app/backend/templates/v2/**' | |
| # Formatting work should happen in a single job so that we push all commits at once, | |
| # because pushing a commit will cause the currently running workflow to abort. | |
| autoformat: | |
| name: Auto-format | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Log in as the bot and checkout the PR branch | |
| - uses: actions/create-github-app-token@v2 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Get GitHub App User ID | |
| id: get-user-id | |
| run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Configure git for GitHub App | |
| run: | | |
| git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
| git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| # Format backend | |
| - name: Install uv | |
| if: needs.detect-changes.outputs.backend == 'true' | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "0.9.6" | |
| - name: Format backend | |
| if: needs.detect-changes.outputs.backend == 'true' | |
| continue-on-error: true | |
| working-directory: app/backend | |
| run: make format | |
| - name: Commit frontend formatting changes | |
| if: needs.detect-changes.outputs.backend == 'true' | |
| run: | | |
| git add "app/backend/**/*.py" | |
| git diff --staged --quiet || git commit -m "Format backend" | |
| # Format frontend | |
| - name: Setup Node.js | |
| if: needs.detect-changes.outputs.frontend == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install frontend dependencies | |
| if: needs.detect-changes.outputs.frontend == 'true' | |
| working-directory: app/web | |
| run: yarn install --frozen-lockfile | |
| - name: Format frontend | |
| if: needs.detect-changes.outputs.frontend == 'true' | |
| continue-on-error: true | |
| working-directory: app/web | |
| run: yarn format | |
| - name: Commit frontend formatting changes | |
| if: needs.detect-changes.outputs.frontend == 'true' | |
| run: | | |
| git add app/web/ | |
| git diff --staged --quiet || git commit -m "Format frontend" | |
| # Format mobile | |
| - name: Setup Node.js | |
| if: needs.detect-changes.outputs.mobile == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install mobile dependencies | |
| if: needs.detect-changes.outputs.mobile == 'true' | |
| continue-on-error: true | |
| working-directory: app/mobile | |
| run: npm ci | |
| - name: Format mobile | |
| if: needs.detect-changes.outputs.mobile == 'true' | |
| working-directory: app/mobile | |
| run: npm run format | |
| - name: Commit mobile formatting changes | |
| if: needs.detect-changes.outputs.mobile == 'true' | |
| run: | | |
| git add app/mobile/ | |
| git diff --staged --quiet || git commit -m "Format mobile" | |
| # Generate email HTML templates | |
| - name: Regenerate HTML from MJML templates | |
| if: needs.detect-changes.outputs.templates == 'true' | |
| continue-on-error: true | |
| working-directory: app/backend/templates/v2 | |
| run: bash _build.sh | |
| - name: Commit and push HTML template changes | |
| if: needs.detect-changes.outputs.templates == 'true' | |
| run: | | |
| git add "app/backend/templates/v2/generated_html/*.html" | |
| git diff --staged --quiet || git commit -m "Regenerate HTML templates" | |
| # Push any commits at once, so we only invalidate the workflow once | |
| - name: Push changes | |
| run: git push | |
| generate-migration: | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.models == 'true' && needs.detect-changes.outputs.migrations == 'false' && github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgis/postgis:18-3.6 | |
| env: | |
| POSTGRES_PASSWORD: testpassword | |
| POSTGRES_DB: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/create-github-app-token@v2 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Get GitHub App User ID | |
| id: get-user-id | |
| run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Configure git for GitHub App | |
| run: | | |
| git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
| git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Generate protobuf files | |
| working-directory: app/backend | |
| run: make protos | |
| - name: Create PostGIS extensions | |
| env: | |
| PGPASSWORD: testpassword | |
| run: | | |
| psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS postgis;" | |
| psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" | |
| psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS btree_gist;" | |
| - name: Load backend.dev.env | |
| run: grep -v '^#' app/backend.dev.env | grep '=' >> "$GITHUB_ENV" | |
| - name: Override database connection string | |
| run: echo "DATABASE_CONNECTION_STRING=postgresql://postgres:testpassword@localhost:5432/postgres" >> "$GITHUB_ENV" | |
| - name: Run all existing migrations | |
| working-directory: app/backend | |
| run: uv run alembic upgrade head | |
| - name: Check if migration is needed | |
| id: check-migration | |
| working-directory: app/backend | |
| run: | | |
| if uv run alembic check; then | |
| echo "needed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "needed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Generate migration | |
| if: steps.check-migration.outputs.needed == 'true' | |
| working-directory: app/backend | |
| run: | | |
| uv run alembic revision --autogenerate -m "${{ github.event.pull_request.title }}" | |
| # Remove Alembic auto-generated comment lines | |
| sed -i '/###.*Alembic/d' src/couchers/migrations/versions/*.py | |
| - name: Format backend | |
| working-directory: app/backend | |
| run: make format | |
| - name: Commit and push migration if created | |
| run: | | |
| git add "app/backend/src/couchers/migrations/versions/*.py" | |
| git diff --staged --quiet || (git commit -m "Generate migrations" && git push) |