mango-v4/.github/workflows/ci-docker-publish.yml

61 lines
1.7 KiB
YAML
Raw Normal View History

2022-08-08 12:06:27 -07:00
name: Publish Docker Image to GCR
on:
push:
branches: [mc/docker]
workflow_call:
secrets:
GCR_PROJECT:
required: true
GCR_SA_KEY:
required: true
env:
PROJECT_ID: ${{ secrets.GCR_PROJECT }}
IMAGE: mango-v4
jobs:
2022-08-08 12:06:27 -07:00
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
2022-08-02 09:59:59 -07:00
with:
submodules: recursive
2022-08-04 06:20:47 -07:00
# Use docker buildx
- name: Use docker buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
2022-08-04 08:59:40 -07:00
buildkitd-flags: --debug
2022-08-04 06:20:47 -07:00
# 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 }}'
2022-08-02 11:52:07 -07:00
# Login to GCR
- name: Login to GCR
uses: docker/login-action@v2
with:
2022-08-04 09:05:52 -07:00
registry: us-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
2022-08-02 11:52:07 -07:00
# Build and push the image, leveraging layer caching
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
2022-08-05 09:50:43 -07:00
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