Build and push container image #97
This file contains hidden or 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 container image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_tags: | |
| required: false | |
| default: "next" | |
| release: | |
| types: [released] | |
| jobs: | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install qemu dependency | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qemu-user-static | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set environment | |
| run: | | |
| if [ "${{ github.event_name }}" == "release" ]; then | |
| # https://github.com/orgs/community/discussions/64736 | |
| latest_tag=$( | |
| curl -L \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ github.token }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases/latest | | |
| jq -r '.tag_name' | |
| ) | |
| tags=${{ github.ref_name }} | |
| if [ "${latest_tag}" == "${{ github.ref_name }}" ]; then | |
| tags="${tags} latest" | |
| fi | |
| echo "RELEASE_TAGS=${tags}" >> $GITHUB_ENV | |
| else | |
| if [ -z "${{ github.event.inputs.release_tags }}" ]; then | |
| exit 1 | |
| fi | |
| echo "RELEASE_TAGS=${{ github.event.inputs.release_tags }}" >> $GITHUB_ENV | |
| fi | |
| - name: Build container image | |
| id: build_image | |
| uses: redhat-actions/buildah-build@v2 | |
| with: | |
| containerfiles: ./Containerfile | |
| image: retis | |
| tags: ${{ env.RELEASE_TAGS }} | |
| archs: amd64, arm64 | |
| - name: Push container image | |
| id: push_image | |
| uses: redhat-actions/push-to-registry@v2 | |
| with: | |
| image: ${{ steps.build_image.outputs.image }} | |
| tags: ${{ steps.build_image.outputs.tags }} | |
| registry: quay.io/retis | |
| username: ${{ secrets.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_TOKEN }} | |
| - name: Summary | |
| run: | | |
| echo "${{ toJSON(steps.push_image.outputs) }}" |