mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-06-22 04:11:32 +10:00
Use native runners for CI (#342)
* feat: use platform-specific runners * feat: replace with template * fix: image name * fix: registry image name * fix: checkout repo * fix: add drop version * fix: add sha env * fix: permissions
This commit is contained in:
@@ -8,11 +8,20 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: "0 2 * * *" # run at 2 AM UTC
|
- cron: "0 2 * * *" # run at 2 AM UTC
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_IMAGE: ghcr.io/drop-oss/drop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
web:
|
build:
|
||||||
name: Build Docker image
|
strategy:
|
||||||
# self-hosted runner to speed things up
|
fail-fast: false
|
||||||
runs-on: [self-hosted, linux]
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux/amd64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
- platform: linux/arm64
|
||||||
|
runner: ubuntu-24.04-arm
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
contents: read
|
contents: read
|
||||||
@@ -26,6 +35,30 @@ jobs:
|
|||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Determine final version
|
- name: Determine final version
|
||||||
id: get_final_ver
|
id: get_final_ver
|
||||||
run: |
|
run: |
|
||||||
@@ -44,22 +77,58 @@ jobs:
|
|||||||
echo "Drop's release tag will be: $FINAL_VER"
|
echo "Drop's release tag will be: $FINAL_VER"
|
||||||
echo "final_ver=$FINAL_VER" >> $GITHUB_OUTPUT
|
echo "final_ver=$FINAL_VER" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Build and push by digest
|
||||||
uses: docker/setup-qemu-action@v3
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
- name: Set up Docker Buildx
|
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
platforms: ${{ matrix.platform }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
tags: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
provenance: mode=max
|
||||||
|
sbom: true
|
||||||
|
build-args: |
|
||||||
|
BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }}
|
||||||
|
BUILD_GIT_REF=${{ github.sha }}
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ runner.temp }}/digests
|
||||||
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: ${{ runner.temp }}/digests/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
@@ -78,33 +147,12 @@ jobs:
|
|||||||
# set latest tag for stable releases
|
# set latest tag for stable releases
|
||||||
type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.release.prerelease == false }}
|
type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.release.prerelease == false }}
|
||||||
|
|
||||||
- name: Cache
|
- name: Create manifest list and push
|
||||||
uses: actions/cache@v4
|
working-directory: ${{ runner.temp }}/digests
|
||||||
id: cache
|
run: |
|
||||||
with:
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
path: cache-mount
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||||
key: cache-mount-${{ hashFiles('Dockerfile') }}
|
|
||||||
|
|
||||||
- name: Restore Docker cache mounts
|
- name: Inspect image
|
||||||
uses: reproducible-containers/buildkit-cache-dance@v3
|
run: |
|
||||||
with:
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
builder: ${{ steps.setup-buildx.outputs.name }}
|
|
||||||
cache-dir: cache-mount
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
|
||||||
|
|
||||||
- name: Build and push image
|
|
||||||
id: build-and-push
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
provenance: mode=max
|
|
||||||
sbom: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
build-args: |
|
|
||||||
BUILD_DROP_VERSION=${{ steps.get_final_ver.outputs.final_ver }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user