Skip to content

Workflow file for this run

---
name: Build and Push Node Project Docker Image to Google Artifact Registry
on:
push:
branches: [main]
permissions:
contents: 'read'
id-token: 'write'
jobs:
build-push-gcr:
name: Build and Push to Google Artifact Registry
runs-on: ubuntu-latest
env:
IMAGE_NAME: fire-daily-bot
PROJECT_ID: fire-daily-news
steps:
- name: Checkout
uses: actions/checkout@v4
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY }}'
- uses: google-github-actions/setup-gcloud@main
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Build Docker Image
run: docker build -t $IMAGE_NAME:latest . --platform=linux/amd64
- name: Automatic Tagging of Releases
id: increment-git-tag
run: |
bash ./scripts/git_update.sh -v major
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: Push Docker Image to Artifact Registry
env:
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |-
docker tag $IMAGE_NAME:latest us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:latest
docker tag $IMAGE_NAME:latest us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:$GIT_TAG
docker push us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:latest
docker push us-central1-docker.pkg.dev/$PROJECT_ID/docker-image/$IMAGE_NAME:$GIT_TAG