|
| 1 | +name: Build dnsmasq oci container image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - gh-actions |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + custom_tag: |
| 10 | + description: optional custom tag on remote repo you want image to be tagged with |
| 11 | + required: false |
| 12 | + default: 'latest' |
| 13 | + type: string |
| 14 | + |
| 15 | +env: |
| 16 | + # Use docker.io for Docker Hub if empty |
| 17 | + REGISTRY: quay.io |
| 18 | + IMAGE_NAME: 3scale/dnsmasq |
| 19 | + |
| 20 | +jobs: |
| 21 | + buildah: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Log in to Red Hat Registry |
| 25 | + uses: redhat-actions/podman-login@v1 |
| 26 | + with: |
| 27 | + registry: ${{ env.REGISTRY }} |
| 28 | + username: ${{ secrets.QUAY_USER_NAME }} |
| 29 | + password: ${{ secrets.QUAY_PASSWORD }} |
| 30 | + |
| 31 | + - name: Meta |
| 32 | + id: meta |
| 33 | + uses: docker/metadata-action@v5 |
| 34 | + with: |
| 35 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 36 | + tags: | |
| 37 | + type=schedule |
| 38 | + type=ref,event=branch,enable=${{ github.ref_name != 'main' && inputs.custom_tag == '' }} |
| 39 | + type=raw,value=latest,enable=${{ github.ref_name == 'main' }} |
| 40 | + type=raw,value=nightly,enable=${{ github.ref_name == 'main' }} |
| 41 | + ${{ inputs.custom_tag }} |
| 42 | + type=ref,event=tag |
| 43 | + type=ref,event=pr |
| 44 | +
|
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Build image |
| 48 | + id: build-image |
| 49 | + uses: redhat-actions/buildah-build@v2 |
| 50 | + with: |
| 51 | + tags: ${{ steps.meta.outputs.tags }} |
| 52 | + labels: ${{ steps.meta.outputs.labels }} |
| 53 | + layers: false |
| 54 | + oci: true |
| 55 | + tls-verify: true |
| 56 | + extra-args: | |
| 57 | + --squash |
| 58 | + containerfiles: | |
| 59 | + Containerfile |
| 60 | +
|
| 61 | + - name: Echo Outputs |
| 62 | + run: | |
| 63 | + echo "Image: ${{ steps.build-image.outputs.image }}" |
| 64 | + echo "Tags: ${{ steps.build-image.outputs.tags }}" |
| 65 | + echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}" |
| 66 | +
|
| 67 | + - name: Check images created |
| 68 | + run: buildah images |
| 69 | + |
| 70 | + - name: Push To quay.io |
| 71 | + id: push-to-quay |
| 72 | + uses: redhat-actions/push-to-registry@v2 |
| 73 | + if: github.event_name != 'pull_request' |
| 74 | + with: |
| 75 | + tags: ${{ steps.build-image.outputs.tags }} |
| 76 | + |
| 77 | + - name: Print image url |
| 78 | + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" |
| 79 | + |
0 commit comments