Switch docker push to be triggered on new release #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cross-Compile Docker Build and Push | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- closed | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- platform: 'linux/amd64' | |
ccarch: 'x86_64' | |
- platform: 'linux/arm64' | |
ccarch: 'aarch64' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Generate Docker metadata | |
id: metadata | |
uses: docker/metadata-action@v3 | |
with: | |
images: greenden/oracle-core | |
tags: | | |
type=sha | |
- name: Build images | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
tags: ${{ steps.metadata.outputs.tags }} | |
build-args: | | |
TARGETPLATFORM=${{ matrix.platform }} | |
CCARCH=${{ matrix.ccarch }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max | |
push: false | |
load: true | |
push: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Combine and Push to DockerHub | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
tags: greenden/oracle-core:${{ github.sha }}, greenden/oracle-core:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
push: true |