Refactor docker-publish.yml to optimize caching strategy

This commit is contained in:
jarvis2f 2024-04-07 17:21:49 +08:00
parent 225ab9ea96
commit 3ace305a67

View File

@ -18,14 +18,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.4.0
with:
cosign-release: "v2.1.1"
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v3.0.0
@ -71,23 +63,8 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
cache-from: type=registry,ref=jarvis2f/vortex:buildcache
cache-to: type=registry,ref=jarvis2f/vortex:buildcache,mode=max
- name: Dockerhub Readme
if: github.event_name != 'pull_request'