Build and Push Docker Image #217
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: Build and Push Docker Image | |
permissions: {} | |
on: | |
push: | |
branches-ignore: | |
- main | |
workflow_dispatch: | |
inputs: | |
name: | |
type: choice | |
required: true | |
description: Docker image name | |
options: | |
- build-android-rust | |
- build-linux-rust | |
- build-windows-rust | |
- package-aar | |
- package-aar-jdk-17 | |
version: | |
type: string | |
required: true | |
description: Output Docker image version | |
rust_version: | |
type: string | |
required: false | |
description: Version of Rust base image for builder images | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-docker-and-push: | |
if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main' | |
runs-on: ubuntu-22.04 | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | |
with: | |
context: . | |
file: builders/${{ inputs.name }}/Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
platforms: |- | |
${{ (github.event.inputs.name == 'build-linux-rust' || github.event.inputs.name == 'build-windows-rust') && 'linux/amd64,linux/arm64' || | |
'linux/amd64' }} | |
push: true | |
tags: ${{ env.REGISTRY }}/nordsecurity/${{ inputs.name }}${{ inputs.rust_version }}:${{ inputs.version }} | |
build-args: | | |
REVISION=${{ github.sha }} | |
build-docker-on-branch: | |
if: github.event_name == 'push' | |
strategy: | |
matrix: | |
name: | |
- build-android-rust | |
- build-linux-rust | |
- build-windows-rust | |
- package-aar | |
- package-aar-jdk-17 | |
runs-on: ubuntu-22.04 | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | |
with: | |
context: . | |
file: builders/${{ matrix.name }}/Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
platforms: |- | |
${{ (matrix.name == 'build-linux-rust' || matrix.name == 'build-windows-rust') && 'linux/amd64,linux/arm64' || | |
'linux/amd64' }} | |
push: true | |
tags: ${{ env.REGISTRY }}/nordsecurity/${{ matrix.name }}:debug-${{ github.sha }} | |
build-args: | | |
REVISION=${{ github.sha }} |