Some checks failed
Build and Push Container Image / build-and-push (push) Failing after 5s
54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
name: Build and Push Container Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: orchestration-platform
|
|
container:
|
|
image: docker:latest
|
|
|
|
steps:
|
|
- name: Install git
|
|
run: apk add --no-cache git
|
|
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --branch "${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" .
|
|
|
|
- name: Determine image tag
|
|
id: meta
|
|
run: |
|
|
if echo "${{ gitea.ref }}" | grep -q "refs/tags/"; then
|
|
TAG=$(echo "${{ gitea.ref }}" | sed 's|refs/tags/||')
|
|
else
|
|
TAG="latest"
|
|
fi
|
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup registry auth
|
|
run: |
|
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
|
AUTH=$(echo -n "${{ gitea.actor }}:${{ secrets.REGISTRY_TOKEN }}" | base64)
|
|
mkdir -p ~/.docker
|
|
cat > ~/.docker/config.json <<EOF
|
|
{
|
|
"auths": {
|
|
"${REGISTRY_HOST}": {
|
|
"auth": "${AUTH}"
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
- name: Build and push image
|
|
run: |
|
|
REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
|
IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}:${{ steps.meta.outputs.tag }}"
|
|
docker build -t "${IMAGE}" .
|
|
docker push "${IMAGE}" |