|
| 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: Create and publish a Docker image |
| 11 | + |
| 12 | +on: |
| 13 | + release: |
| 14 | + types: [published] |
| 15 | + |
| 16 | +env: |
| 17 | + REGISTRY: ghcr.io |
| 18 | + IMAGE_NAME: ${{ github.repository }} |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-and-push-image: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + packages: write |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Log in to the Container registry |
| 32 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
| 33 | + with: |
| 34 | + registry: ${{ env.REGISTRY }} |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Extract metadata (tags, labels) for Docker |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 41 | + with: |
| 42 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 43 | + tags: | |
| 44 | + type=semver,pattern={{version}} |
| 45 | + type=semver,pattern={{major}} |
| 46 | +
|
| 47 | + - name: Build and push Docker image |
| 48 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
| 49 | + with: |
| 50 | + context: . |
| 51 | + push: true |
| 52 | + tags: ${{ steps.meta.outputs.tags }} |
| 53 | + labels: ${{ steps.meta.outputs.labels }} |
| 54 | + |
| 55 | + |
0 commit comments