Skip to content

Docker Image Publish on Release #4

Docker Image Publish on Release

Docker Image Publish on Release #4

name: Docker Image Publish on Release
on:
release:
types: [published]
env:
IMAGE_NAME: spn-pbp-amr
jobs:
build-to-test:
uses: ./.github/workflows/docker-image-build-to-test.yml
build-and-push-image:
needs: build-to-test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=pep440,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
target: app
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}