|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +# GitHub recommends pinning actions to a commit SHA. |
| 7 | +# To get a newer version, you will need to update the SHA. |
| 8 | +# You can also reference a tag or branch, but the action may change without warning. |
| 9 | + |
| 10 | +name: Publish Docker image |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + tags: |
| 15 | + - 'v*' |
| 16 | + branches: |
| 17 | + - master |
| 18 | + release: |
| 19 | + types: [published] |
| 20 | + |
| 21 | +jobs: |
| 22 | + push_to_registry: |
| 23 | + name: Push Docker image to Docker Hub |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + packages: write |
| 27 | + contents: read |
| 28 | + attestations: write |
| 29 | + id-token: write |
| 30 | + steps: |
| 31 | + - name: Check out the repo |
| 32 | + uses: actions/checkout@v5 |
| 33 | + |
| 34 | + - name: Log in to Docker Hub |
| 35 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
| 36 | + with: |
| 37 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 38 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 39 | + |
| 40 | + - name: Extract metadata (tags, labels) for Docker |
| 41 | + id: meta |
| 42 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 43 | + with: |
| 44 | + images: ${{ secrets.DOCKER_USERNAME }}/aio |
| 45 | + tags: | |
| 46 | + type=ref,event=branch |
| 47 | + type=semver,pattern={{version}} |
| 48 | + type=semver,pattern={{major}}.{{minor}} |
| 49 | + type=sha |
| 50 | + type=raw,value=latest,enable={{is_default_branch}} |
| 51 | +
|
| 52 | + - name: Build and push Docker image |
| 53 | + id: push |
| 54 | + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 |
| 55 | + with: |
| 56 | + context: . |
| 57 | + file: ./Dockerfile |
| 58 | + push: true |
| 59 | + tags: ${{ steps.meta.outputs.tags }} |
| 60 | + labels: ${{ steps.meta.outputs.labels }} |
| 61 | + platforms: linux/amd64,linux/arm64 |
| 62 | + |
| 63 | + - name: Generate artifact attestation |
| 64 | + uses: actions/attest-build-provenance@v3 |
| 65 | + with: |
| 66 | + subject-name: index.docker.io/${{ secrets.DOCKER_USERNAME }}/aio |
| 67 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 68 | + push-to-registry: true |
0 commit comments