This commit is contained in:
YuCat-OVO 2024-03-02 18:01:35 +08:00
parent 4f339389f7
commit a5f194c6a4

View File

@ -31,11 +31,13 @@ jobs:
GITHUB_REF=${{ github.ref }}
BRACH=${GITHUB_REF#refs/heads/}
DATE=$(date '+%Y-%m-%dT%H:%M:%S%Z')
PLATFORM_PAIR=${{ matrix.arch }}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "GITHUB_REF=${GITHUB_REF}" >> $GITHUB_OUTPUT
echo "BRACH=${BRACH}" >> $GITHUB_OUTPUT
echo "DATE=${DATE}" >> $GITHUB_OUTPUT
echo "PLATFORM_PAIR=${PLATFORM_PAIR//\//-}" >> $GITHUB_ENV
- name: Docker Meta
id: meta
@ -43,7 +45,7 @@ jobs:
with:
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
# ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.set-vars.outputs.VERSION }}
type=raw,value=${{ steps.set-vars.outputs.BRACH }}
@ -61,25 +63,116 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Login to GHCR
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Buildx
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: |
${{ matrix.arch }}
push: true
platforms: ${{ matrix.arch }}
build-args: |
BUILD_DATE=${{ steps.set-vars.outputs.DATE }}
VERSION=${{ steps.set-vars.outputs.VERSION }}
BAIDUNETDISK_VERSION=${{ steps.set-vars.outputs.BAIDUNETDISK_VERSION }}
BAIDUNETDISK_URL=${{ steps.set-vars.outputs.BAIDUNETDISK_URL }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
outputs: type=image,name=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.set-vars.outputs.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# - name: Buildx
# uses: docker/build-push-action@v5
# with:
# context: .
# file: Dockerfile
# platforms: |
# ${{ matrix.arch }}
# push: true
# build-args: |
# BUILD_DATE=${{ steps.set-vars.outputs.DATE }}
# VERSION=${{ steps.set-vars.outputs.VERSION }}
# BAIDUNETDISK_VERSION=${{ steps.set-vars.outputs.BAIDUNETDISK_VERSION }}
# BAIDUNETDISK_URL=${{ steps.set-vars.outputs.BAIDUNETDISK_URL }}
# labels: ${{ steps.meta.outputs.labels }}
# tags: ${{ steps.meta.outputs.tags }}
Merge:
runs-on: ubuntu-latest
needs:
- Build
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set variables
id: set-vars
run: |
VERSION="1.0.2"
GITHUB_REF=${{ github.ref }}
BRACH=${GITHUB_REF#refs/heads/}
DATE=$(date '+%Y-%m-%dT%H:%M:%S%Z')
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "GITHUB_REF=${GITHUB_REF}" >> $GITHUB_OUTPUT
echo "BRACH=${BRACH}" >> $GITHUB_OUTPUT
echo "DATE=${DATE}" >> $GITHUB_OUTPUT
- 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: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
# ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.set-vars.outputs.VERSION }}
type=raw,value=${{ steps.set-vars.outputs.BRACH }}
type=raw,value=latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# - name: Login to GHCR
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect $${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}