61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: Publish Docker Image to GCR
|
|
|
|
on:
|
|
push:
|
|
branches: [dev]
|
|
workflow_call:
|
|
secrets:
|
|
GCR_PROJECT:
|
|
required: true
|
|
GCR_SA_KEY:
|
|
required: true
|
|
|
|
env:
|
|
PROJECT_ID: ${{ secrets.GCR_PROJECT }}
|
|
IMAGE: mango-v4
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: recursive
|
|
|
|
# Use docker buildx
|
|
- name: Use docker buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
id: buildx
|
|
with:
|
|
install: true
|
|
buildkitd-flags: --debug
|
|
|
|
# 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, leveraging layer caching
|
|
- name: Build and Push
|
|
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=registry,ref=us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}:buildcache
|
|
cache-to: type=registry,ref=us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}:buildcache,mode=max
|