mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
name: Docker Build
|
|
description: Common steps to build a Docker image for a specific platform
|
|
inputs:
|
|
platform:
|
|
description: Target platform (e.g., amd64, arm64)
|
|
required: true
|
|
token:
|
|
description: GitHub token for authentication
|
|
required: true
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Set lowercase repository name
|
|
run: echo "REPOSITORY_LC=${REPOSITORY,,}" >> "$GITHUB_ENV"
|
|
shell: bash
|
|
env:
|
|
REPOSITORY: ${{ github.repository }}
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
|
- name: Login to GitHub registry
|
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
|
with:
|
|
username: ${{ github.actor }}
|
|
password: ${{ inputs.token }}
|
|
registry: ghcr.io
|
|
- name: Build and push by digest
|
|
id: build
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
platforms: linux/${{ inputs.platform }}
|
|
outputs: >-
|
|
type=image,
|
|
name=ghcr.io/${{ env.REPOSITORY_LC }},
|
|
push-by-digest=true,
|
|
name-canonical=true,
|
|
push=true
|
|
cache-from: >-
|
|
type=gha,
|
|
scope=build-${{ inputs.platform }}
|
|
cache-to: >-
|
|
type=gha,
|
|
mode=max,
|
|
scope=build-${{ inputs.platform }}
|
|
- name: Export digest
|
|
shell: bash
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: digests-${{ inputs.platform }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|