Skip to content

Commit

Permalink
Setup image build/push GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
phenixblue committed Aug 31, 2023
1 parent a75d060 commit d77fad7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci-image-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: image-build

on:
release:
# Dynamic releasetag tag is set based on the assumption this ci task only runs on release
types: [published]

# Variables to be used throughout the workflow manifest
env:
# TO-DO (@phenixblue): Need to investigate more into why the `linux/ppc64le`
# platform has issues with installing Python dependencies during image build.
#
# Removing for now to not block
TARGET_PLATFORMS: linux/amd64,linux/arm64
jobs:

# Build and push imageswap-init container image
build-and-push-image:
name: Build and push TWR Tools image to DockerHub
runs-on: ubuntu-latest

steps:

- name: Check out the repo
uses: actions/checkout@v2

# Collect Release Tag is used to to collect information needed later in the action and expose it so it can be referenced
- name: Collect Release Tag
id: prep
# GITHUB_REF variable must exist in action; this may rely on {{ on: release: types: [published] }} gating the action
run: |
echo ::set-output name=releasetag::${GITHUB_REF#refs/tags/}
# Setup QEMU to support multi-arch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# Part of docker/build-push-action@v2; setting up the build system
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Part of docker/build-push-action@v2; login to dockerhub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push imageswap-init image to DockerHub
if: github.repository == 'phenixblue/twrtools'
timeout-minutes: 30
uses: docker/build-push-action@v2
with:
context: ./
# file should be specified relative to the repo root rather than relative to the context
file: ./Dockerfile
# Defines the target platform architectures images should be built for
platforms: ${{ env.TARGET_PLATFORMS }}
# push is no longer defaulted to true under v2; to push you must specify push is true
push: true
# Uses the releasetag output exposed by the Collect Release Tag step to set the tag under v2
tags: jmsearcy/twrtools:${{ steps.prep.outputs.releasetag }},jmsearcy/twrtools:latest
6 changes: 0 additions & 6 deletions docker-compose.yaml

This file was deleted.

0 comments on commit d77fad7

Please sign in to comment.