Files
SwiftLint/.github/workflows/docker.yml
T
Bradley Mackey ad30ecef67 Build and provide ARM64 Linux binaries (#6015)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-08-16 17:31:23 +02:00

111 lines
3.2 KiB
YAML

name: Docker
on:
schedule:
- cron: '0 3 * * 3' # Every Wednesday at 03:00 UTC
push:
branches:
- main
paths:
- '.github/workflows/docker.yml'
- 'Dockerfile'
- 'tools/build-linux-release.sh'
release:
types: published
workflow_call:
inputs:
ref:
description: 'Git reference'
required: true
type: string
tag:
description: 'Docker tag'
required: true
type: string
pull_request:
paths:
- '.github/workflows/docker.yml'
- 'Dockerfile'
- 'tools/build-linux-release.sh'
permissions:
contents: read
packages: write
jobs:
build:
name: Build Images
runs-on: ubuntu-24.04-arm
steps:
- name: Define variables on push to `main`
if: github.event_name == 'schedule' || github.event_name == 'push'
run: |
{
echo "CHECKOUT_REF=main"
echo "DOCKER_TAG=latest"
echo "OUTPUT_TYPE=type=registry"
} >> "$GITHUB_ENV"
- name: Define variables on release event
if: github.event_name == 'release'
run: |
{
echo "CHECKOUT_REF=${{ github.event.release.tag_name }}"
echo "DOCKER_TAG=${{ github.event.release.tag_name }}"
echo "OUTPUT_TYPE=type=registry"
} >> "$GITHUB_ENV"
- name: Define variables on pull request
if: github.event_name == 'pull_request'
run: |
{
echo "CHECKOUT_REF=pr"
echo "DOCKER_TAG=pr-${{ github.event.pull_request.number }}"
echo "OUTPUT_TYPE=type=local,dest=artifacts"
} >> "$GITHUB_ENV"
- name: Define variables on workflow call
if: env.DOCKER_TAG == null
run: |
{
echo "CHECKOUT_REF=${{ inputs.ref }}"
echo "DOCKER_TAG=${{ inputs.tag }}"
echo "OUTPUT_TYPE=type=local,dest=artifacts"
} >> "$GITHUB_ENV"
- uses: actions/checkout@v4
if: env.CHECKOUT_REF == 'pr'
- uses: actions/checkout@v4
if: env.CHECKOUT_REF != 'pr'
with:
ref: ${{ env.CHECKOUT_REF }}
- name: Set lowercase repository name
run: echo "REPOSITORY_LC=${REPOSITORY,,}" >> "$GITHUB_ENV"
env:
REPOSITORY: ${{ github.repository }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64
- 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:
context: .
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{ env.DOCKER_TAG }}
platforms: linux/amd64, linux/arm64
outputs: ${{ env.OUTPUT_TYPE }}
- name: Move binary artifacts
if: contains(env.OUTPUT_TYPE, 'local')
run: mv artifacts/linux_*/usr/bin/swiftlint_linux_* .
- name: Upload binary artifacts
if: contains(env.OUTPUT_TYPE, 'local')
uses: actions/upload-artifact@v4
with:
name: swiftlint_linux
path: swiftlint_linux_*
if-no-files-found: error
retention-days: 2