blob: 3d30f7fa7defa2b11b068e14b8a19d7d5ac8064e [file] [log] [blame]
Davide Pesavento273e80f2023-09-20 23:28:11 -04001name: Publish Docker image
Varun Patilaad8dbe2022-09-19 09:49:58 +09002
3on:
4 push:
Davide Pesavento273e80f2023-09-20 23:28:11 -04005 branches:
6 - master
7 workflow_dispatch:
Varun Patilaad8dbe2022-09-19 09:49:58 +09008
9env:
10 REGISTRY: ghcr.io
11 IMAGE_NAME: ${{ github.repository }}
12
13jobs:
Davide Pesavento273e80f2023-09-20 23:28:11 -040014 publish:
Varun Patilaad8dbe2022-09-19 09:49:58 +090015 runs-on: ubuntu-latest
16 permissions:
17 contents: read
18 packages: write
19
20 steps:
21 - name: Checkout repository
Davide Pesavento273e80f2023-09-20 23:28:11 -040022 uses: actions/checkout@v4
Varun Patilaad8dbe2022-09-19 09:49:58 +090023
Davide Pesavento273e80f2023-09-20 23:28:11 -040024 - name: Login to ${{ env.REGISTRY }}
25 uses: docker/login-action@v3
Varun Patilaad8dbe2022-09-19 09:49:58 +090026 with:
27 registry: ${{ env.REGISTRY }}
28 username: ${{ github.actor }}
29 password: ${{ secrets.GITHUB_TOKEN }}
30
Davide Pesavento273e80f2023-09-20 23:28:11 -040031 - name: Extract metadata for Docker
Varun Patilaad8dbe2022-09-19 09:49:58 +090032 id: meta
Davide Pesavento273e80f2023-09-20 23:28:11 -040033 uses: docker/metadata-action@v5
Varun Patilaad8dbe2022-09-19 09:49:58 +090034 with:
35 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36
37 - name: Build and push Docker image
Davide Pesavento273e80f2023-09-20 23:28:11 -040038 uses: docker/build-push-action@v5
Varun Patilaad8dbe2022-09-19 09:49:58 +090039 with:
40 context: .
Davide Pesavento273e80f2023-09-20 23:28:11 -040041 pull: true
Varun Patilaad8dbe2022-09-19 09:49:58 +090042 push: true
43 tags: ${{ steps.meta.outputs.tags }}
44 labels: ${{ steps.meta.outputs.labels }}