Skip to content

Publish docker image #3

Publish docker image

Publish docker image #3

name: "Publish docker image"
on:
workflow_dispatch:
# Run on PRs to main to make sure everything works, but we skip the publishing.
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-22.04
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout latest tag
run: |
git fetch --tags
TAG=$(git tag -l --sort=v:refname | tail -1)
echo "TAG=$TAG" >> $GITHUB_ENV
git checkout $TAG
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository_owner }}/explain-dalibo-com/pev2:${{ env.TAG }}
ghcr.io/${{ github.repository_owner }}/explain-dalibo-com/pev2:latest