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

87 lines
2.5 KiB
YAML
Raw Normal View History

2022-08-08 12:06:27 -07:00
name: Publish Docker Image to GCR
2022-11-05 06:10:34 -07:00
on:
push:
branches: [dev,main]
2022-11-04 10:32:06 -07:00
paths: ['.github/ci-docker-publish.yml',
2022-11-05 06:00:04 -07:00
'programs/**',
2022-11-04 10:32:06 -07:00
'client/**',
'keeper/**',
'liquidator/**']
workflow_call:
secrets:
GCR_PROJECT:
required: true
GCR_SA_KEY:
required: true
2022-11-05 06:10:34 -07:00
workflow_dispatch:
env:
PROJECT_ID: ${{ secrets.GCR_PROJECT }}
IMAGE: mango-v4
jobs:
2022-08-08 12:14:07 -07:00
build:
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 }}
# Build and push the base image, leveraging layer caching
- name: Build and Push Base Image
2022-08-02 11:52:07 -07:00
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=gha
cache-to: type=gha,mode=max
# Build and push the liquidator runtime image
- name: Build and Push Liquidator
uses: docker/build-push-action@v2
with:
file: liquidator/Dockerfile.liquidator
context: .
push: true
tags: |
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}-liquidator:${{ github.sha }}
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}-liquidator:latest
# Build and push the keeper runtime image
- name: Build and Push Keeper
uses: docker/build-push-action@v2
with:
2022-08-31 04:52:30 -07:00
file: keeper/Dockerfile.keeper
context: .
push: true
tags: |
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}-keeper:${{ github.sha }}
us-docker.pkg.dev/${{ env.PROJECT_ID }}/gcr.io/${{ env.IMAGE }}-keeper:latest