|
| 1 | +name: Build zync oci container image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + platforms: |
| 7 | + description: comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le |
| 8 | + default: linux/amd64 |
| 9 | + type: string |
| 10 | + custom_tag: |
| 11 | + description: optional custom tag on remote repo you want image to be tagged with |
| 12 | + required: false |
| 13 | + default: '' |
| 14 | + type: string |
| 15 | + secrets: |
| 16 | + QUAY_USER_NAME: |
| 17 | + required: false |
| 18 | + QUAY_PASSWORD: |
| 19 | + required: false |
| 20 | + |
| 21 | +env: |
| 22 | + # Use docker.io for Docker Hub if empty |
| 23 | + REGISTRY: quay.io |
| 24 | + # github.repository as <account>/<repo> |
| 25 | + IMAGE_NAME: ${{ github.repository }} |
| 26 | + |
| 27 | +jobs: |
| 28 | + buildah: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + # Allow multi-target builds |
| 32 | + # - name: Set up QEMU |
| 33 | + # uses: docker/setup-qemu-action@v2 |
| 34 | + # with: |
| 35 | + # platforms: ${{ inputs.platforms }} |
| 36 | + |
| 37 | + - name: Log in to Red Hat Registry |
| 38 | + uses: redhat-actions/podman-login@v1 |
| 39 | + with: |
| 40 | + registry: ${{ env.REGISTRY }} |
| 41 | + username: ${{ secrets.QUAY_USER_NAME }} |
| 42 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 43 | + |
| 44 | + - name: Docker meta |
| 45 | + id: meta |
| 46 | + uses: docker/metadata-action@v5 |
| 47 | + with: |
| 48 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 49 | + tags: | |
| 50 | + type=schedule |
| 51 | + type=ref,event=branch,enable=${{ github.ref_name != 'master' && inputs.custom_tag == '' }} |
| 52 | + type=raw,value=latest,enable=${{ github.ref_name == 'master' }} |
| 53 | + type=raw,value=nightly,enable=${{ github.ref_name == 'master' }} |
| 54 | + ${{ inputs.custom_tag }} |
| 55 | + type=ref,event=tag |
| 56 | + type=ref,event=pr |
| 57 | +
|
| 58 | + - uses: actions/checkout@v6 |
| 59 | + |
| 60 | + - name: Build image |
| 61 | + id: build-image |
| 62 | + uses: redhat-actions/buildah-build@v2 |
| 63 | + with: |
| 64 | + tags: ${{ steps.meta.outputs.tags }} |
| 65 | + # enable platforms once base image has them |
| 66 | + # platforms: ${{ inputs.platforms }} |
| 67 | + labels: ${{ steps.meta.outputs.labels }} |
| 68 | + layers: false |
| 69 | + oci: true |
| 70 | + tls-verify: true |
| 71 | + extra-args: | |
| 72 | + --squash |
| 73 | + containerfiles: | |
| 74 | + Dockerfile |
| 75 | +
|
| 76 | + - name: Echo Outputs |
| 77 | + run: | |
| 78 | + echo "Image: ${{ steps.build-image.outputs.image }}" |
| 79 | + echo "Tags: ${{ steps.build-image.outputs.tags }}" |
| 80 | + echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}" |
| 81 | +
|
| 82 | + - name: Check images created |
| 83 | + run: buildah images |
| 84 | + |
| 85 | + - name: Push To quay.io |
| 86 | + id: push-to-quay |
| 87 | + uses: redhat-actions/push-to-registry@v2 |
| 88 | + if: github.event_name != 'pull_request' |
| 89 | + with: |
| 90 | + tags: ${{ steps.build-image.outputs.tags }} |
| 91 | + |
| 92 | + - name: Print image url |
| 93 | + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" |
0 commit comments