Skip to content

Merge pull request #64 from nhudson/renovate/octocrab-0.x #65

Merge pull request #64 from nhudson/renovate/octocrab-0.x

Merge pull request #64 from nhudson/renovate/octocrab-0.x #65

# .github/workflows/docker-publish.yml
name: Build and Publish Docker
on:
push:
branches:
- main
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Add release tag
id: release_tag
run: |
if [[ ${{ github.ref }} == refs/tags/* ]]; then
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Set version arg
id: version_tag
run: |
if [[ ${{ github.ref }} == refs/heads/main ]]; then
echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
fi
- name: docker build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
build-args: |
VERSION=${{ steps.version_tag.outputs.VERSION }}
tags: |
ghcr.io/${{ github.repository }}:${{ steps.version_tag.outputs.VERSION }}
${{ steps.release_tag.outputs.RELEASE_VERSION != '' && 'ghcr.io/${{ github.repository }}:${{ steps.release_tag.outputs.RELEASE_VERSION }}' || '' }}
${{ steps.release_tag.outputs.RELEASE_VERSION != '' && 'ghcr.io/${{ github.repository }}:latest' || '' }}
platforms: ${{ matrix.platform }}