Merge pull request #65 from nhudson/renovate/octocrab-0.x #68
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 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 }} |