chore(deps): bump axum-extra from 0.9.3 to 0.9.4 #514
This file contains 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: exporter | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- "*" | |
env: | |
CARGO_TERM_COLOR: always | |
SQLX_VERSION: 0.8.2 | |
SQLX_FEATURES: postgres | |
jobs: | |
fmt-lint-test: | |
name: format, lint and test | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:14 | |
env: | |
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }} | |
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }} | |
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }} | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }} | |
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }} | |
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }} | |
POSTGRES_HOST: localhost | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .env | |
run: ./scripts/create_env.sh | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-targets: true | |
- name: Check Format | |
run: cargo fmt --all -- --check | |
- uses: taiki-e/install-action@nextest | |
- name: Cache sqlx-cli | |
uses: actions/cache@v4 | |
id: cache-sqlx | |
with: | |
path: | | |
~/.cargo/bin/sqlx | |
~/.cargo/bin/cargo-sqlx | |
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }} | |
- name: Install sqlx-cli | |
if: steps.cache-sqlx.outputs.cache-hit == false | |
run: | | |
cargo install sqlx-cli \ | |
--force \ | |
--version=${{ env.SQLX_VERSION }} \ | |
--features ${{ env.SQLX_FEATURES }} \ | |
--no-default-features \ | |
--locked | |
- name: Migrate database | |
run: | | |
sudo apt-get install libpq-dev -y | |
./scripts/init_db.sh | |
- name: Lint | |
if: github.actor != 'dependabot[bot]' | |
run: | | |
cargo clippy -- -D warnings | |
- name: Check sqlx offline query | |
if: github.actor != 'dependabot[bot]' | |
run: | | |
cd apps/exporter | |
cargo sqlx prepare --check -- --bin swu-exporter | |
- name: Run tests | |
run: | | |
cd apps/exporter | |
cargo nextest run | |
build-deploy: | |
name: build and deploy | |
runs-on: ubuntu-latest | |
needs: | |
- fmt-lint-test | |
environment: production | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Exporter Google Sheet Credentials | |
env: | |
EXPORTER_SHEETS_CREDENTIALS: ${{secrets.EXPORTER_SHEETS_CREDENTIALS}} | |
run: | | |
mkdir credentials | |
echo $EXPORTER_SHEETS_CREDENTIALS > credentials/exporter.json | |
- name: Login | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
install_components: beta | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Image Metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ vars.CLOUD_RUN_EXPORTER_IMAGE }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=sha | |
- name: Login to GAR | |
uses: docker/login-action@v3 | |
with: | |
registry: us-central1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- name: Build production image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
provenance: false | |
file: apps/exporter/Dockerfile | |
target: runtime | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ vars.CLOUD_RUN_EXPORTER_IMAGE }}:buildcache | |
cache-to: type=registry,ref=${{ vars.CLOUD_RUN_EXPORTER_IMAGE }}:buildcache,mode=max | |
- name: Replace variables in exporter-job.yaml | |
run: | | |
sed -i s#%EXPORTER_IMAGE%#${{ fromJSON(steps.meta.outputs.json).tags[1] }}#g exporter-job.yaml | |
sed -i s#%SERVICE_ACCOUNT%#${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }}#g exporter-job.yaml | |
- name: Update Cloud Run Job | |
run: | | |
gcloud run jobs replace exporter-job.yaml --region=us-central1 --project=${{ secrets.GCP_PROJECT_ID }} |