57 lines
1.4 KiB
YAML
57 lines
1.4 KiB
YAML
name: Publish Docker Image to GCR
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
workflow_call:
|
|
secrets:
|
|
GCR_PROJECT:
|
|
required: false
|
|
GCR_SA_KEY:
|
|
required: false
|
|
|
|
env:
|
|
PROJECT_ID: ${{ secrets.GCR_PROJECT }}
|
|
IMAGE: mango-geyser-services
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@master
|
|
|
|
# Login to Google Cloud
|
|
- name: 'Login to Google Cloud'
|
|
uses: 'google-github-actions/auth@v0'
|
|
id: auth
|
|
with:
|
|
token_format: 'access_token'
|
|
credentials_json: '${{ secrets.GCR_SA_KEY }}'
|
|
|
|
# Login to GCR
|
|
- name: Login to GCR
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: us-docker.pkg.dev
|
|
username: oauth2accesstoken
|
|
password: ${{ steps.auth.outputs.access_token }}
|
|
|
|
# Build and push the image
|
|
- name: Build and Push Image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}:${{ github.sha }}
|
|
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|