Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 1 | name: Publish Docker image |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 2 | |
| 3 | on: |
| 4 | push: |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 5 | branches: |
| 6 | - master |
| 7 | workflow_dispatch: |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 8 | |
| 9 | env: |
| 10 | REGISTRY: ghcr.io |
| 11 | IMAGE_NAME: ${{ github.repository }} |
| 12 | |
| 13 | jobs: |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 14 | publish: |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 15 | runs-on: ubuntu-latest |
| 16 | permissions: |
| 17 | contents: read |
| 18 | packages: write |
| 19 | |
| 20 | steps: |
| 21 | - name: Checkout repository |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 22 | uses: actions/checkout@v4 |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 23 | |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 24 | - name: Login to ${{ env.REGISTRY }} |
| 25 | uses: docker/login-action@v3 |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 26 | with: |
| 27 | registry: ${{ env.REGISTRY }} |
| 28 | username: ${{ github.actor }} |
| 29 | password: ${{ secrets.GITHUB_TOKEN }} |
| 30 | |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 31 | - name: Extract metadata for Docker |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 32 | id: meta |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 33 | uses: docker/metadata-action@v5 |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 34 | with: |
| 35 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 36 | |
| 37 | - name: Build and push Docker image |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 38 | uses: docker/build-push-action@v5 |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 39 | with: |
| 40 | context: . |
Davide Pesavento | 273e80f | 2023-09-20 23:28:11 -0400 | [diff] [blame] | 41 | pull: true |
Varun Patil | aad8dbe | 2022-09-19 09:49:58 +0900 | [diff] [blame] | 42 | push: true |
| 43 | tags: ${{ steps.meta.outputs.tags }} |
| 44 | labels: ${{ steps.meta.outputs.labels }} |