Build and Publish #462
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 Publish | |
on: | |
push: | |
branches: | |
- redhat-** # IMPORTANT! this must match the jobs.build-and-publish.env.BRANCH_PREFIX (save the **). | |
workflow_dispatch: | |
# Allows you to run this workflow manually from the Actions tab | |
inputs: | |
tag: | |
description: 'Tag to attach to image' | |
required: true | |
jobs: | |
build-and-publish: | |
name: Publish container image | |
env: | |
BRANCH_PREFIX: redhat- # IMPORTANT! this must match the .on.push.branches prefix! | |
REGISTRY: quay.io/projectquay | |
REPO_NAME: ${{ github.event.repository.name }} | |
TAG_SUFFIX: -unstable | |
runs-on: 'ubuntu-latest' | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Set version from branch name | |
id: version-from-branch | |
if: startsWith('env.BRANCH_PREFIX', env.GITHUB_REF) | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
echo "::set-output name=version::${BRANCH_NAME/${{ env.BRANCH_PREFIX }}/}" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Quay.io | |
uses: docker/login-action@v1 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USER }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
env: | |
TAG: ${{ steps.version-from-branch.outputs.version }}${{ env.TAG_SUFFIX }} | |
with: | |
platforms: linux/amd64,linux/s390x,linux/ppc64le | |
build-args: BUILDER_SRC=github.com/quay/quay-builder | |
push: true | |
file: Dockerfile | |
tags: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}:${{ github.event.inputs.tag || env.TAG }} | |