Skip to content

Merge pull request #849 from hwakabh/dependabot/npm_and_yarn/api-serv… #140

Merge pull request #849 from hwakabh/dependabot/npm_and_yarn/api-serv…

Merge pull request #849 from hwakabh/dependabot/npm_and_yarn/api-serv… #140

Workflow file for this run

name: Backend CI
on:
push:
branches:
- main
# All updates except api-server/** will be ignored
paths:
- 'api-server/**'
workflow_dispatch:
env:
MAIL_API_KEY: ${{ secrets.MAIL_API_KEY }}
TUMBLR_CONSUMER_KEY: ${{ secrets.TUMBLR_CONSUMER_KEY }}
jobs:
build-and-ship:
name: Build & Ship OCI image
runs-on: ubuntu-24.04
# For Workload Identity & push to GHCR
permissions:
contents: 'read'
packages: 'write'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v6
# https://github.com/docker/login-action#github-container-registry
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/buildpacks/github-actions#setup-pack-cli-action
- name: Install pack
uses: buildpacks/github-actions/setup-pack@v5.9.7
# Google Cloud buildpacks
# https://cloud.google.com/docs/buildpacks/builders
# https://cloud.google.com/docs/buildpacks/nodejs
- name: Publish packages
run: |
pack build ghcr.io/hwakabh/gh-pages-api:latest \
--builder gcr.io/buildpacks/builder:latest \
--path ./api-server/ \
--publish
# https://github.com/google-github-actions/auth
- name: Auth with Google Cloud
id: auth
uses: 'google-github-actions/auth@v3'
with:
workload_identity_provider: 'projects/1037550336239/locations/global/workloadIdentityPools/default-pool/providers/default-provider'
service_account: 'gh-action-cloudrun@hwakabh-dev.iam.gserviceaccount.com'
token_format: access_token
# https://github.com/google-github-actions/deploy-cloudrun
- uses: 'google-github-actions/deploy-cloudrun@v3'
with:
image: 'us-central1-docker.pkg.dev/hwakabh-dev/ghcr/hwakabh/gh-pages-api:latest'
service: 'gh-pages-api-server'
flags: '--service-min-instances=1'
env_vars: |
MAIL_API_KEY=${{ env.MAIL_API_KEY }}
TUMBLR_CONSUMER_KEY=${{ env.TUMBLR_CONSUMER_KEY }}