Skip to content

Add build target

Add build target #4

Workflow file for this run

# Builds image and stores in ghcr.io then sends webhook to deploy new image
name: Podman Image CI
on:
push:
branches: [ "main", "staging", "develop", "sandbox", "cjcolvar-patch-4" ]
env:
GHCR_USER: ${{ github.actor }}
GHCR_PASSWORD: ${{ github.token }}
GHCR_IMAGE_REGISTRY: ghcr.io/avalonmediasystem
DOCKERHUB_IMAGE_REGISTRY: docker.io/avalonmediasystem
DOCKERHUB_USER: ${{ secrets.dockerhub_user }}
DOCKERHUB_PASSWORD: ${{ secrets.dockerhub_password }}
IMAGE_TAG: ${{ fromJSON('{"refs/heads/main":"production","refs/heads/develop":"develop","refs/heads/staging":"staging","refs/heads/sandbox":"sandbox","refs/heads/cjcolvar-patch-4":"develop"}')[github.ref] }}
BRANCH: ${{ fromJSON('{"refs/heads/main":"main","refs/heads/develop":"develop","refs/heads/staging":"staging","refs/heads/sandbox":"sandbox","refs/heads/cjcolvar-patch-4":"develop"}')[github.ref] }}
BUILD_TARGET: ${{ fromJSON('{"refs/heads/main":"prod","refs/heads/develop":"dev","refs/heads/staging":"prod","refs/heads/sandbox":"prod","refs/heads/cjcolvar-patch-4":"dev"}')[github.ref] }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: avalon
tags: ${{ env.IMAGE_TAG }} ${{ github.sha }}
containerfiles: ./Dockerfile
oci: true
extra-args: --target ${{ env.BUILD_TARGET }}
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.GHCR_IMAGE_REGISTRY }}
username: ${{ env.GHCR_USER }}
password: ${{ env.GHCR_PASSWORD }}
extra-args: |
--disable-content-trust
- name: Determine develop image tags
if: ${{ env.IMAGE_TAG == 'develop' }}
id: determine_dockerhub_tags
run: |
AVALON_VERSION=`script/avalon_image_tags.rb -t`
echo "AVALON_VERSION=${AVALON_VERSION}" >> "$GITHUB_OUTPUT"
echo "tags=`script/avalon_image_tags.rb --branch ${BRANCH} -a ${AVALON_VERSION}-dev` >> "$GITHUB_OUTPUT"
- name: Develop Push To Dockerhub
if: ${{ env.IMAGE_TAG == 'develop' }}
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.determine_dockerhub_tags.outputs.tags }}
registry: ${{ env.DOCKERHUB_IMAGE_REGISTRY }}
username: ${{ env.DOCKERHUB_USER }}
password: ${{ env.DOCKERHUB_PASSWORD }}
extra-args: |
--disable-content-trust