feat: UI design system refresh across app screens #695
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: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| env: | |
| MIX_ENV: test | |
| ELIXIR_VERSION: "1.18.4" | |
| OTP_VERSION: "28.0.2" | |
| jobs: | |
| test: | |
| name: Build & Test | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: ksef_hub_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ env.ELIXIR_VERSION }} | |
| otp-version: ${{ env.OTP_VERSION }} | |
| - name: Restore dependencies cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: mix-${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }} | |
| restore-keys: | | |
| mix-${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Check formatting | |
| run: mix format --check-formatted | |
| - name: Compile (warnings as errors) | |
| run: mix compile --warnings-as-errors | |
| - name: Run Credo | |
| run: mix credo --strict | |
| - name: Run tests | |
| run: mix test | |
| env: | |
| DATABASE_URL: ecto://postgres:postgres@localhost/ksef_hub_test | |
| deploy: | |
| name: Deploy | |
| needs: [test] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: deploy-production | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| GCP_PROJECT_ID: au-ksef-ex | |
| GCP_REGION: europe-west1 | |
| AR_REPO: ksef-hub | |
| SERVICE_NAME: ksef-hub | |
| IMAGE_NAME: europe-west1-docker.pkg.dev/au-ksef-ex/ksef-hub/ksef-hub | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker "${GCP_REGION}-docker.pkg.dev" --quiet | |
| - name: Build Docker image | |
| run: | | |
| docker build \ | |
| -t "${IMAGE_NAME}:${{ github.sha }}" \ | |
| -t "${IMAGE_NAME}:latest" \ | |
| . | |
| - name: Push Docker image | |
| run: | | |
| docker push "${IMAGE_NAME}:${{ github.sha }}" | |
| docker push "${IMAGE_NAME}:latest" | |
| - name: Build and push ksef-pdf sidecar | |
| env: | |
| KSEF_PDF_IMAGE: europe-west1-docker.pkg.dev/au-ksef-ex/ksef-hub/ksef-pdf | |
| run: | | |
| git clone --depth 1 --branch feature/html-output \ | |
| https://github.com/appunite/ksef-pdf-generator.git /tmp/ksef-pdf | |
| docker build \ | |
| -t "${KSEF_PDF_IMAGE}:${{ github.sha }}" \ | |
| -t "${KSEF_PDF_IMAGE}:latest" \ | |
| /tmp/ksef-pdf | |
| docker push "${KSEF_PDF_IMAGE}:${{ github.sha }}" | |
| docker push "${KSEF_PDF_IMAGE}:latest" | |
| - name: Run database migrations | |
| run: | | |
| MIGRATE_ARGS=( | |
| --region "${GCP_REGION}" | |
| --image "${IMAGE_NAME}:${{ github.sha }}" | |
| --command "bin/ksef_hub" | |
| --set-secrets "DATABASE_URL=database-url:latest,SECRET_KEY_BASE=secret-key-base:latest,GOOGLE_CLIENT_ID=google-client-id:latest,GOOGLE_CLIENT_SECRET=google-client-secret:latest,CREDENTIAL_ENCRYPTION_KEY=credential-encryption-key:latest" | |
| --set-env-vars "KSEF_API_URL=https://api.ksef.mf.gov.pl,POOL_SIZE=2" | |
| --service-account "ksef-hub-runner@${GCP_PROJECT_ID}.iam.gserviceaccount.com" | |
| ) | |
| if gcloud run jobs describe ksef-hub-migrate --region "${GCP_REGION}" > /dev/null 2>&1; then | |
| gcloud run jobs update ksef-hub-migrate "${MIGRATE_ARGS[@]}" | |
| gcloud run jobs execute ksef-hub-migrate \ | |
| --region "${GCP_REGION}" \ | |
| --wait \ | |
| --args "eval,KsefHub.Release.migrate()" | |
| else | |
| gcloud run jobs create ksef-hub-migrate \ | |
| "${MIGRATE_ARGS[@]}" \ | |
| --execute-now \ | |
| --wait \ | |
| --args "eval,KsefHub.Release.migrate()" | |
| fi | |
| - name: Deploy to Cloud Run | |
| run: | | |
| sed "s|IMAGE_PLACEHOLDER|${IMAGE_NAME}:${{ github.sha }}|g" \ | |
| cloud-run/service.yaml | \ | |
| gcloud run services replace - \ | |
| --region "${GCP_REGION}" | |
| - name: Ensure service allows traffic | |
| run: | | |
| if ! gcloud run services get-iam-policy "${SERVICE_NAME}" \ | |
| --region "${GCP_REGION}" \ | |
| --format="value(bindings.members)" 2>/dev/null | grep -q "allUsers"; then | |
| gcloud run services add-iam-policy-binding "${SERVICE_NAME}" \ | |
| --region "${GCP_REGION}" \ | |
| --member="allUsers" \ | |
| --role="roles/run.invoker" \ | |
| --quiet | |
| fi |