Skip to content

Publish Docker Image #1

Publish Docker Image

Publish Docker Image #1

Workflow file for this run

name: Build and Push Docker Image to GHCR on Release
# Trigger the workflow when a new release is created
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Check out the repository containing the Dockerfile and other necessary files
- name: Checkout repository
uses: actions/checkout@v3
# Set up Docker Buildx for advanced build features like multi-platform builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to GitHub Container Registry (GHCR)
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
# Build and push the Docker image to GHCR with the 'latest' and release tags
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}/myapp:latest
ghcr.io/${{ github.repository }}/myapp:${{ github.event.release.tag_name }}