mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
Optimize CI
This commit is contained in:
@@ -16,6 +16,10 @@ permissions:
|
||||
attestations: write
|
||||
id-token: write
|
||||
|
||||
env:
|
||||
IMAGE_NAME: wavelet
|
||||
DOCKERFILE: docker/Dockerfile
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.arch }})
|
||||
@@ -46,7 +50,8 @@ jobs:
|
||||
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
||||
INPUT_VERSION="${INPUT_VERSION//[[:space:]]/}"
|
||||
|
||||
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
||||
OWNER="${GITHUB_REPOSITORY_OWNER,,}"
|
||||
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||
@@ -76,28 +81,27 @@ jobs:
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
file: ${{ env.DOCKERFILE }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
build-args: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
BUILD_DATE=${{ env.BUILD_DATE }}
|
||||
cache-from: type=gha,scope=docker-server-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,ignore-error=true,timeout=20m,scope=docker-server-${{ matrix.arch }}
|
||||
cache-from: type=gha,scope=docker-${{ env.IMAGE_NAME }}-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,ignore-error=true,timeout=20m,scope=docker-${{ env.IMAGE_NAME }}-${{ matrix.arch }}
|
||||
|
||||
- name: Export digest
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/server-digests
|
||||
touch "/tmp/server-digests/${DIGEST#sha256:}"
|
||||
mkdir -p "/tmp/${{ env.IMAGE_NAME }}-digests"
|
||||
touch "/tmp/${{ env.IMAGE_NAME }}-digests/${DIGEST#sha256:}"
|
||||
env:
|
||||
DIGEST: ${{ steps.build.outputs.digest }}
|
||||
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: server-digests-${{ matrix.arch }}
|
||||
path: /tmp/server-digests/*
|
||||
name: ${{ env.IMAGE_NAME }}-digests-${{ matrix.arch }}
|
||||
path: /tmp/${{ env.IMAGE_NAME }}-digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
@@ -128,7 +132,8 @@ jobs:
|
||||
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
||||
INPUT_VERSION="${INPUT_VERSION//[[:space:]]/}"
|
||||
|
||||
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
||||
OWNER="${GITHUB_REPOSITORY_OWNER,,}"
|
||||
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||
@@ -145,8 +150,8 @@ jobs:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/server-digests
|
||||
pattern: server-digests-*
|
||||
path: /tmp/${{ env.IMAGE_NAME }}-digests
|
||||
pattern: ${{ env.IMAGE_NAME }}-digests-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
@@ -160,7 +165,7 @@ jobs:
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create and push manifest list
|
||||
working-directory: /tmp/server-digests
|
||||
working-directory: /tmp/${{ env.IMAGE_NAME }}-digests
|
||||
shell: bash
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
@@ -170,7 +175,7 @@ jobs:
|
||||
done
|
||||
|
||||
if [ ${#references[@]} -eq 0 ]; then
|
||||
echo "No digests found in /tmp/server-digests" >&2
|
||||
echo "No digests found in /tmp/${{ env.IMAGE_NAME }}-digests" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -184,9 +189,11 @@ jobs:
|
||||
-t "${IMAGE}:${VERSION}" \
|
||||
-t "${IMAGE}:${FLOATING_TAG}" \
|
||||
"${references[@]}"
|
||||
env:
|
||||
IMAGE: ${{ env.IMAGE }}
|
||||
|
||||
- name: Inspect image
|
||||
run: docker buildx imagetools inspect "${IMAGE}:${VERSION}"
|
||||
run: docker buildx imagetools inspect "${{ env.IMAGE }}:${{ env.VERSION }}"
|
||||
|
||||
- name: Trigger webhook
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user