Update .gitea/workflows/build-and-push.yaml
Some checks failed
Build and Push Container Image / build-and-push (push) Failing after 11s
Some checks failed
Build and Push Container Image / build-and-push (push) Failing after 11s
This commit is contained in:
@@ -11,16 +11,16 @@ jobs:
|
|||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: orchestration-platform
|
runs-on: orchestration-platform
|
||||||
container:
|
container:
|
||||||
image: docker:27-cli
|
image: docker:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install tools
|
- name: Install tools
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache git
|
apk add --no-cache git curl
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
git clone --depth 1 --branch "${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" .
|
git clone --branch "${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" .
|
||||||
|
|
||||||
- name: Check Dockerfile
|
- name: Check Dockerfile
|
||||||
run: |
|
run: |
|
||||||
@@ -29,27 +29,39 @@ jobs:
|
|||||||
- name: Determine image metadata
|
- name: Determine image metadata
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||; s|/.*$||')
|
if echo "${{ gitea.ref }}" | grep -q "refs/tags/"; then
|
||||||
IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}"
|
TAG=$(echo "${{ gitea.ref }}" | sed 's|refs/tags/||')
|
||||||
|
|
||||||
if echo "${{ gitea.ref }}" | grep -q '^refs/tags/'; then
|
|
||||||
TAG=$(echo "${{ gitea.ref }}" | sed 's|refs/tags/v\?||')
|
|
||||||
EXTRA_TAG=""
|
|
||||||
else
|
else
|
||||||
TAG="latest"
|
TAG="latest"
|
||||||
EXTRA_TAG="main-${{ gitea.sha }}"
|
|
||||||
fi
|
fi
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
id: build
|
||||||
|
run: |
|
||||||
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||||
|
IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}:${{ steps.meta.outputs.tag }}"
|
||||||
|
docker build \
|
||||||
|
--label "org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}" \
|
||||||
|
--label "org.opencontainers.image.revision=${{ gitea.sha }}" \
|
||||||
|
-t "${IMAGE}" \
|
||||||
|
.
|
||||||
echo "registry_host=${REGISTRY_HOST}" >> "$GITHUB_OUTPUT"
|
echo "registry_host=${REGISTRY_HOST}" >> "$GITHUB_OUTPUT"
|
||||||
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
|
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "extra_tag=${EXTRA_TAG}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Login to Gitea registry
|
- name: Login to Gitea registry
|
||||||
run: |
|
run: |
|
||||||
REGISTRY_USERNAME="${{ secrets.REGISTRY_USERNAME }}"
|
REGISTRY_USERNAME="${{ secrets.REGISTRY_USERNAME }}"
|
||||||
REGISTRY_TOKEN="${{ secrets.REGISTRY_TOKEN }}"
|
REGISTRY_TOKEN="${{ secrets.REGISTRY_TOKEN }}"
|
||||||
|
|
||||||
|
if [ -z "${REGISTRY_TOKEN}" ]; then
|
||||||
|
REGISTRY_TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${REGISTRY_TOKEN}" ]; then
|
||||||
|
REGISTRY_TOKEN="${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${REGISTRY_USERNAME}" ]; then
|
if [ -z "${REGISTRY_USERNAME}" ]; then
|
||||||
REGISTRY_USERNAME="${{ gitea.actor }}"
|
REGISTRY_USERNAME="${{ gitea.actor }}"
|
||||||
fi
|
fi
|
||||||
@@ -60,34 +72,15 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${REGISTRY_TOKEN}" ]; then
|
if [ -z "${REGISTRY_TOKEN}" ]; then
|
||||||
echo "Registry token is missing. Set REGISTRY_TOKEN as a repository or organization secret."
|
echo "Registry token is missing. Set REGISTRY_TOKEN, GITEA_TOKEN, or enable the built-in GITHUB_TOKEN for this workflow."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${REGISTRY_TOKEN}" | docker login \
|
echo "${REGISTRY_TOKEN}" | docker login \
|
||||||
"${{ steps.meta.outputs.registry_host }}" \
|
"${{ steps.build.outputs.registry_host }}" \
|
||||||
--username "${REGISTRY_USERNAME}" \
|
--username "${REGISTRY_USERNAME}" \
|
||||||
--password-stdin
|
--password-stdin
|
||||||
|
|
||||||
- name: Build image
|
|
||||||
run: |
|
|
||||||
docker build \
|
|
||||||
--label "org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}" \
|
|
||||||
--label "org.opencontainers.image.revision=${{ gitea.sha }}" \
|
|
||||||
-t "${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}" \
|
|
||||||
.
|
|
||||||
|
|
||||||
- name: Add trace tag
|
|
||||||
if: ${{ steps.meta.outputs.extra_tag != '' }}
|
|
||||||
run: |
|
|
||||||
docker tag \
|
|
||||||
"${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}" \
|
|
||||||
"${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.extra_tag }}"
|
|
||||||
|
|
||||||
- name: Push image
|
- name: Push image
|
||||||
run: |
|
run: |
|
||||||
docker push "${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.tag }}"
|
docker push "${{ steps.build.outputs.image }}"
|
||||||
|
|
||||||
if [ -n "${{ steps.meta.outputs.extra_tag }}" ]; then
|
|
||||||
docker push "${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.extra_tag }}"
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user