Skip to content

Docker

Docker #188

Workflow file for this run

name: Docker
on:
push:
tags:
- 'v*.*.*'
pull_request:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_BUILD_ARGS: "${{ vars.DOCKER_BUILD_ARGS }}"
jobs:
release:
name: Release
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/anzbank/sysl-go
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{raw}}
type=sha,prefix=,format=long
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.url=https://sysl.io
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build test docker container image
run: |
docker buildx build \
--platform linux/amd64 \
--output type=docker \
--build-arg SYSLGO_VERSION=${{ github.ref }} \
${{ env.DOCKER_BUILD_ARGS && format('--build-arg {0}', env.DOCKER_BUILD_ARGS) }} \
-t local/sysl-go-test:test .
- name: Download container-structure-test
env:
CONTAINER_STRUCTURE_TEST: ${{ vars.CONTAINER_STRUCTURE_TEST || 'https://storage.googleapis.com/container-structure-test/v1.15.0/container-structure-test-linux-amd64' }}
run: |
curl -LO ${CONTAINER_STRUCTURE_TEST} && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
- name: Test container image
env:
image: local/sysl-go-test:test
config: container-structure-tests.yaml
run: |
container-structure-test test --image $image --config $config --no-color
- name: Login to DockerHub
# only attempt to push if we are in the open source repo that has credentials, and there's been a push, not merely a pull request.
if: github.repository == 'anz-bank/sysl-go' && github.event_name == 'push'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build and push docker container image
# only attempt to push if we are in the open source repo that has credentials, and there's been a push, not merely a pull request.
if: github.repository == 'anz-bank/sysl-go' && github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: .
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
SYSLGO_VERSION=${{ github.ref }}
${{ env.DOCKER_BUILD_ARGS }}