Skip to content

Add cross-build Dockerfile and DockerHub publish action #2

Add cross-build Dockerfile and DockerHub publish action

Add cross-build Dockerfile and DockerHub publish action #2

name: Cross-Compile Docker Build and Push
on:
pull_request:
types:
- opened
- synchronize
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: Generate Docker metadata
id: metadata
uses: docker/metadata-action@v3
with:
images: greenden/oracle-core
tags: |
type=ref,event=tag
- 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 }}
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.ref_name }}, greenden/oracle-core:latest
push: true