fix: rewrite composite action using shell only (act_runner nested uses limitation)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
name: Docker Build & Push
|
||||
description: >
|
||||
Standard libreshop image build+push pipeline. Logs into the registry,
|
||||
computes semver/branch/sha tags via metadata-action, builds and
|
||||
optionally pushes the image.
|
||||
computes branch/tag/sha tags, builds and optionally pushes the image.
|
||||
|
||||
inputs:
|
||||
context:
|
||||
@@ -33,42 +32,47 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
shell: bash
|
||||
run: docker buildx create --use 2>/dev/null || docker buildx use default 2>/dev/null || true
|
||||
|
||||
- name: Log in to registry
|
||||
if: inputs.publish == 'true'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ inputs.registry }}
|
||||
username: ${{ inputs.registry_user }}
|
||||
password: ${{ inputs.registry_pass }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "${{ inputs.registry_pass }}" | \
|
||||
docker login "${{ inputs.registry }}" \
|
||||
-u "${{ inputs.registry_user }}" --password-stdin
|
||||
|
||||
- name: Compute image name
|
||||
id: name
|
||||
- name: Build and push
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${{ inputs.image_name }}" ]; then
|
||||
echo "value=${{ inputs.image_name }}" >> $GITHUB_OUTPUT
|
||||
IMAGE="${{ inputs.image_name }}"
|
||||
else
|
||||
echo "value=${{ inputs.registry }}/${{ github.repository }}" >> $GITHUB_OUTPUT
|
||||
IMAGE="${{ inputs.registry }}/${{ github.repository }}"
|
||||
fi
|
||||
|
||||
- name: Compute tags and labels
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ steps.name.outputs.value }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=sha,prefix=sha-,format=short
|
||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
REF="${{ github.ref }}"
|
||||
SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
TAGS="-t ${IMAGE}:sha-${SHA}"
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ${{ inputs.context }}
|
||||
file: ${{ inputs.dockerfile }}
|
||||
push: ${{ inputs.publish == 'true' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
if [[ "${REF}" == refs/heads/* ]]; then
|
||||
BRANCH="${REF#refs/heads/}"
|
||||
TAGS="${TAGS} -t ${IMAGE}:${BRANCH}"
|
||||
fi
|
||||
|
||||
if [[ "${REF}" == refs/tags/* ]]; then
|
||||
TAG="${REF#refs/tags/}"
|
||||
TAGS="${TAGS} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest"
|
||||
fi
|
||||
|
||||
PUSH_FLAG=""
|
||||
if [ "${{ inputs.publish }}" = "true" ]; then
|
||||
PUSH_FLAG="--push"
|
||||
fi
|
||||
|
||||
docker buildx build \
|
||||
--file "${{ inputs.dockerfile }}" \
|
||||
${TAGS} \
|
||||
${PUSH_FLAG} \
|
||||
"${{ inputs.context }}"
|
||||
|
||||
Reference in New Issue
Block a user