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