chore(deps): bump docker/build-push-action from 4 to 5 #172
Workflow file for this run
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: CI/CD | |
on: | |
- push | |
- pull_request | |
jobs: | |
test: | |
name: Test | |
permissions: | |
contents: read | |
runs-on: ubuntu-latest | |
container: | |
image: rust:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Install `tailwindcss` | |
run: > | |
curl | |
-L https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 | |
-o /usr/local/bin/tailwindcss | |
&& chmod +x /usr/local/bin/tailwindcss | |
- name: Execute tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --no-fail-fast | |
check: | |
name: Check | |
permissions: | |
contents: read | |
runs-on: ubuntu-latest | |
container: | |
image: rust:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Install `tailwindcss` | |
run: > | |
curl | |
-L https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 | |
-o /usr/local/bin/tailwindcss | |
&& chmod +x /usr/local/bin/tailwindcss | |
- name: Install `clippy` | |
run: rustup component add clippy | |
- name: Check code | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --all-features --all-targets -- -D warnings | |
format: | |
name: Format | |
permissions: | |
contents: read | |
runs-on: ubuntu-latest | |
container: | |
image: rustlang/rust:nightly | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Check formatting | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
build: | |
name: Build | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- check | |
- format | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Generate Docker metadata | |
id: docker-metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/vidhanio/site | |
us-east1-docker.pkg.dev/vidhan-io/site/site | |
tags: | | |
type=ref,event=branch | |
type=sha | |
flavor: | | |
latest=true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Google Cloud | |
id: gcloud-auth | |
uses: google-github-actions/auth@v1 | |
with: | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
- name: Login to Google Artifact Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: us-east1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcloud-auth.outputs.access_token }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.docker-metadata.outputs.tags }} | |
labels: ${{ steps.docker-metadata.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy: | |
name: Deploy | |
permissions: | |
contents: read | |
id-token: write | |
environment: | |
name: Production | |
url: https://vidhan.io | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT }} | |
- name: Deploy to Cloud Run | |
id: cloud-run-deploy | |
uses: google-github-actions/deploy-cloudrun@v1 | |
with: | |
service: "site" | |
image: "us-east1-docker.pkg.dev/vidhan-io/site/site:latest" | |
env_vars: | | |
IP=0.0.0.0 | |
PRODUCTION=true | |
region: us-east1 |