Skip to content

1.2.0

1.2.0 #4

name: Build and Push Docker Image
on:
release:
types: [published]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Convert repository name to lowercase
id: repo
run: echo "REPO_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build -t ghcr.io/${{ env.REPO_NAME }}:${{ env.VERSION }} .
docker tag ghcr.io/${{ env.REPO_NAME }}:${{ env.VERSION }} ghcr.io/${{ env.REPO_NAME }}:latest
- name: Push Docker image
run: |
docker push ghcr.io/${{ env.REPO_NAME }}:${{ env.VERSION }}
docker push ghcr.io/${{ env.REPO_NAME }}:latest