|
| 1 | +name: 'Build QNS Docker Image' |
| 2 | +description: 'Build a Docker image for QNS testing' |
| 3 | +author: 'neqo' |
| 4 | + |
| 5 | +inputs: |
| 6 | + ref: |
| 7 | + description: 'Git ref to checkout (SHA, branch, tag)' |
| 8 | + required: false |
| 9 | + default: github.ref |
| 10 | + tag: |
| 11 | + description: 'Tag for the image' |
| 12 | + required: true |
| 13 | + push: |
| 14 | + description: 'Whether to push the image to registry' |
| 15 | + required: false |
| 16 | + default: 'false' |
| 17 | + platforms: |
| 18 | + description: 'Platforms to build for' |
| 19 | + required: false |
| 20 | + default: 'linux/amd64' |
| 21 | + |
| 22 | +outputs: |
| 23 | + image-id: |
| 24 | + description: 'The ID of the built Docker image' |
| 25 | + value: ${{ steps.docker_build.outputs.imageID }} |
| 26 | + artifact-name: |
| 27 | + description: 'The name of the uploaded artifact' |
| 28 | + value: ${{ steps.upload.outputs.artifact-name }} |
| 29 | + |
| 30 | +runs: |
| 31 | + using: "composite" |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 34 | + with: |
| 35 | + ref: ${{ inputs.ref }} |
| 36 | + persist-credentials: false |
| 37 | + |
| 38 | + - uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0 |
| 39 | + id: meta |
| 40 | + with: |
| 41 | + images: ghcr.io/${{ github.repository }}-qns${{ inputs.tag }} |
| 42 | + tags: | |
| 43 | + # default |
| 44 | + type=schedule |
| 45 | + type=ref,event=branch |
| 46 | + type=ref,event=tag |
| 47 | + type=ref,event=pr |
| 48 | + # set latest tag for default branch |
| 49 | + type=raw,value=latest,enable={{is_default_branch}} |
| 50 | +
|
| 51 | + - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 52 | + id: docker_build |
| 53 | + with: |
| 54 | + push: ${{ inputs.push }} |
| 55 | + tags: ${{ steps.meta.outputs.tags }} |
| 56 | + file: qns/Dockerfile |
| 57 | + build-args: RUST_VERSION=stable |
| 58 | + platforms: ${{ inputs.platforms }} |
| 59 | + outputs: type=docker,dest=/tmp/${{ format('{0}.tar', inputs.tag) }} |
| 60 | + |
| 61 | + - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 |
| 62 | + id: upload |
| 63 | + if: ${{ inputs.push == 'false' }} |
| 64 | + with: |
| 65 | + name: ${{ format('{0} Docker image ', inputs.tag) }} |
| 66 | + path: /tmp/${{ format('{0}.tar', inputs.tag) }} |
0 commit comments