diff --git a/.github/workflows/docker-image-publish-on-release.yml b/.github/workflows/docker-image-publish-on-release.yml new file mode 100644 index 0000000..b81c5b5 --- /dev/null +++ b/.github/workflows/docker-image-publish-on-release.yml @@ -0,0 +1,49 @@ +name: Docker Image Publish on Release + +on: + release: + types: [published] + +jobs: + build-and-push-image: + 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 }}/${{ github.event.repository.name }} + ghcr.io/${{ github.repository }} + tags: | + type=semver,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 }} \ No newline at end of file