|
| 1 | +name: "Publish Docker Image" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + # No inputs needed at this time |
| 6 | + |
| 7 | +jobs: |
| 8 | + docker_publish: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + attestations: write |
| 12 | + contents: read |
| 13 | + id-token: write |
| 14 | + packages: write |
| 15 | + |
| 16 | + env: |
| 17 | + DOCKER_IO_REGISTRY: docker.io |
| 18 | + DOCKER_IO_IMAGE_NAME_ALL: helmuthva/oe-python-template-example |
| 19 | + DOCKER_IO_IMAGE_NAME_SLIM: helmuthva/oe-python-template-example-slim |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 24 | + |
| 25 | + - name: Install dev tools |
| 26 | + shell: bash |
| 27 | + run: .github/workflows/_install_dev_tools.bash |
| 28 | + |
| 29 | + - name: Set up QEMU |
| 30 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 31 | + |
| 32 | + - name: Set up Docker Buildx |
| 33 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 34 | + |
| 35 | + |
| 36 | + - name: Log in to Docker Hub |
| 37 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 38 | + with: |
| 39 | + username: ${{ secrets.DOCKER_IO_USERNAME }} |
| 40 | + password: ${{ secrets.DOCKER_IO_PASSWORD }} |
| 41 | + |
| 42 | + |
| 43 | + - name: Log in to GitHub Container Registry |
| 44 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.repository_owner }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Extract metadata for Docker |
| 51 | + id: meta |
| 52 | + uses: docker/metadata-action@38b8a86137171c128513e9be0b97bc476fbffcb5 # v5.6.0 |
| 53 | + with: |
| 54 | + images: | |
| 55 | + ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template-example |
| 56 | +
|
| 57 | + ${{ env.DOCKER_IO_IMAGE_NAME_ALL }} |
| 58 | +
|
| 59 | + flavor: | |
| 60 | + latest=auto |
| 61 | + prefix= |
| 62 | + suffix= |
| 63 | + tags: | |
| 64 | + type=semver,pattern=v |
| 65 | + type=semver,pattern=v. |
| 66 | + type=semver,pattern=v |
| 67 | +
|
| 68 | + - name: Build and push Docker image (all) |
| 69 | + uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0 |
| 70 | + with: |
| 71 | + context: . |
| 72 | + push: true |
| 73 | + tags: ${{ steps.meta.outputs.tags }} |
| 74 | + labels: ${{ steps.meta.outputs.labels }} |
| 75 | + platforms: linux/amd64,linux/arm64 |
| 76 | + target: all |
| 77 | + provenance: true |
| 78 | + cache-from: type=gha |
| 79 | + cache-to: type=gha,mode=max |
| 80 | + |
| 81 | + - name: Build and push Docker image (slim) |
| 82 | + uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0 |
| 83 | + with: |
| 84 | + context: . |
| 85 | + push: true |
| 86 | + tags: | |
| 87 | + ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template-example-slim:latest |
| 88 | + ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template-example-slim:${{ github.ref_name }} |
| 89 | +
|
| 90 | + ${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}:latest |
| 91 | + ${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}:${{ github.ref_name }} |
| 92 | +
|
| 93 | + labels: ${{ steps.meta.outputs.labels }} |
| 94 | + platforms: linux/amd64,linux/arm64 |
| 95 | + target: slim |
| 96 | + provenance: true |
| 97 | + cache-from: type=gha |
| 98 | + cache-to: type=gha,mode=max |
0 commit comments