Abort in case release tag doesn't yet exist #1568
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
name: Docker Build | |
on: | |
push: | |
branches: | |
- main | |
workflow_call: | |
inputs: | |
ref: | |
description: 'Git reference' | |
required: true | |
type: string | |
tag: | |
description: 'Docker tag' | |
required: true | |
type: string | |
default: 'latest' | |
jobs: | |
build: | |
name: Build Docker Image | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
if: github.event_name != 'push' && inputs.tag != 'latest' | |
with: | |
ref: ${{ inputs.ref }} | |
- uses: actions/checkout@v4 | |
if: github.event_name == 'push' | |
- name: Set Docker tag | |
if: github.event_name != 'push' && inputs.tag != 'latest' | |
run: echo "DOCKER_TAG=${{ inputs.tag }}" >> $GITHUB_ENV | |
- name: Use default Docker tag | |
if: github.event_name == 'push' | |
run: echo "DOCKER_TAG=latest" >> $GITHUB_ENV | |
- name: Set lowercase repository name | |
run: echo "REPOSITORY_LC=${REPOSITORY,,}" >> $GITHUB_ENV | |
env: | |
REPOSITORY: '${{ github.repository }}' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
registry: ghcr.io | |
- uses: docker/build-push-action@v6 | |
with: | |
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ env.DOCKER_TAG }} | |
platforms: linux/amd64 | |
outputs: | | |
type=registry | |
type=local,dest=artifacts | |
- name: Rename binary artifact | |
run: mv artifacts/usr/bin/swiftlint artifacts/usr/bin/swiftlint_linux_amd64 | |
- name: Upload binary artifact | |
if: github.event_name != 'push' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: swiftlint_linux_amd64 | |
path: artifacts/usr/bin/swiftlint_linux_amd64 | |
if-no-files-found: error | |
retention-days: 2 |