chore(ci): optimize docker publish workflow
This commit is contained in:
@@ -5,6 +5,10 @@ on:
|
||||
branches: ["master", "new-dev"]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: docker-publish-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
@@ -21,12 +25,14 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
fetch-depth: 1
|
||||
fetch-tags: true
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: 'arm64,amd64'
|
||||
platforms: arm64
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -51,6 +57,10 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
@@ -66,16 +76,6 @@ jobs:
|
||||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
||||
org.opencontainers.image.revision=${{ github.sha }}
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update version in app.php
|
||||
run: |
|
||||
VERSION=$(date '+%Y%m%d')-$(git rev-parse --short HEAD)
|
||||
sed -i "s/'version' => '.*'/'version' => '$VERSION'/g" config/app.php
|
||||
echo "Updated version to: $VERSION"
|
||||
|
||||
- name: Build and push
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v5
|
||||
@@ -83,18 +83,14 @@ jobs:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-from: type=gha,scope=docker-publish-${{ github.ref_name }}
|
||||
cache-to: type=gha,mode=max,scope=docker-publish-${{ github.ref_name }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
BUILDKIT_INLINE_CACHE=1
|
||||
BUILDKIT_MULTI_PLATFORM=1
|
||||
CACHEBUST=${{ github.sha }}
|
||||
REPO_URL=https://github.com/${{ github.repository }}
|
||||
BRANCH_NAME=${{ github.ref_name }}
|
||||
provenance: false
|
||||
outputs: type=registry,push=true
|
||||
allow: |
|
||||
network.host
|
||||
|
||||
|
||||
Reference in New Issue
Block a user