mirror of
https://github.com/YuCat-OVO/BaiduNetdisk-Docker
synced 2025-05-10 20:10:04 +08:00
187 lines
5.5 KiB
YAML
187 lines
5.5 KiB
YAML
name: Build & Release
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: Version
|
|
required: false
|
|
type: string
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
paths-ignore:
|
|
- ".github/**"
|
|
- "docs/**"
|
|
- "**.md"
|
|
|
|
env:
|
|
DOCKERHUB_SLUG: docker.io/yucatovo/baidunetdisk-docker
|
|
GHCR_SLUG: ghcr.io/yucat-ovo/baidunetdisk-docker
|
|
|
|
jobs:
|
|
prepare:
|
|
name: prepare
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@master
|
|
|
|
- name: Docker Meta
|
|
uses: docker/metadata-action@v5
|
|
id: meta
|
|
with:
|
|
images: |
|
|
${{ env.DOCKERHUB_SLUG }}
|
|
${{ env.GHCR_SLUG }}
|
|
tags: |
|
|
type=ref,event=branch,enable=${{ github.ref_name != github.event.repository.default_branch }}
|
|
type=edge,branch=develop
|
|
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
type=sha
|
|
labels: |
|
|
org.opencontainers.image.title=BaiduNetdisk-Docker
|
|
org.opencontainers.image.description=A BaiduNetdisk image base on Linuxserver.io's KasmVNC image.
|
|
org.opencontainers.image.vendor=YuCat-OVO
|
|
|
|
- name: Rename meta bake definition file
|
|
run: |
|
|
mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json"
|
|
|
|
- name: Upload meta bake definition
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bake-meta
|
|
path: /tmp/bake-meta.json
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- prepare
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform: ["linux/amd64", "linux/arm64"]
|
|
steps:
|
|
- name: Prepare
|
|
run: |
|
|
platform=${{ matrix.platform }}
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
|
echo "ARCH=${platform//linux\//}" >> "$GITHUB_ENV"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download meta bake definition
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bake-meta
|
|
path: /tmp
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-flags: "--debug"
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build
|
|
id: bake
|
|
uses: docker/bake-action@v4
|
|
env:
|
|
ARCH: ${{ env.ARCH }}
|
|
with:
|
|
files: |
|
|
./docker-bake.hcl
|
|
/tmp/bake-meta.json
|
|
targets: image
|
|
set: |
|
|
*.tags=
|
|
*.platform=${{ matrix.platform }}
|
|
*.cache-from=type=gha,scope=build-${{ env.PLATFORM_PAIR }}
|
|
*.cache-to=type=gha,scope=build-${{ env.PLATFORM_PAIR }}
|
|
*.output=type=image,"name=${{ env.DOCKERHUB_SLUG }},${{ env.GHCR_SLUG }}",push-by-digest=true,name-canonical=true,push=true
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: digests-${{ env.PLATFORM_PAIR }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build
|
|
steps:
|
|
- name: Download meta bake definition
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: bake-meta
|
|
path: /tmp
|
|
|
|
- name: Download digests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create manifest list and push
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.DOCKERHUB_SLUG }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
|
|
$(printf '${{ env.DOCKERHUB_SLUG }}@sha256:%s ' *)
|
|
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.GHCR_SLUG }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
|
|
$(printf '${{ env.GHCR_SLUG }}@sha256:%s ' *)
|
|
|
|
- name: Inspect image
|
|
run: |
|
|
tag=$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
|
|
docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${tag}
|
|
docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${tag}
|