4f20f5ae2f
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 28s
CI Main / Check existing artifact (push) Successful in 21s
acc-tests Cucumber test report
CI Main / Cucumber tests (push) Successful in 57s
unit-tests Bats test report
CI Main / Bats tests (push) Failing after 2m13s
CI Main / Build & Push Docker (push) Has been skipped
CI Main / Move provider version tag (push) Has been skipped
CI Main / Report Summary (push) Successful in 6s
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #33
58 lines
1.7 KiB
YAML
58 lines
1.7 KiB
YAML
name: CI Container Build & Push
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
env_json:
|
|
required: true
|
|
type: string
|
|
dockerfile_path:
|
|
required: true
|
|
type: string
|
|
image_name:
|
|
required: true
|
|
type: string
|
|
tag:
|
|
required: false
|
|
type: string
|
|
default: 'latest'
|
|
secrets:
|
|
DOCKER_USERNAME:
|
|
required: false
|
|
DOCKER_PASSWORD:
|
|
required: true
|
|
|
|
jobs:
|
|
build-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build and push container
|
|
env:
|
|
DOCKER_REGISTRY: ${{ fromJson(inputs.env_json).DOCKER_REGISTRY || '' }}
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME || github.actor }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
run: |
|
|
if [ -z "${DOCKER_REGISTRY}" ]; then echo "ERROR: DOCKER_REGISTRY not set in conf"; exit 1; fi
|
|
REGISTRY="${DOCKER_REGISTRY}"
|
|
REGISTRY_HOST="${REGISTRY%%/*}"
|
|
DOCKERFILE="${{ inputs.dockerfile_path }}"
|
|
IMAGE_NAME="${{ inputs.image_name }}"
|
|
TAG="${{ inputs.tag }}"
|
|
|
|
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
docker build \
|
|
--label "git.commit=${{ github.sha }}" \
|
|
--label "git.commitBy=${{ github.actor }}" \
|
|
--label "build.date=${NOW}" \
|
|
-f "${DOCKERFILE}" \
|
|
-t "${IMAGE_NAME}:${TAG}" .
|
|
|
|
FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
|
echo "Pushing ${FULL_IMAGE} ..."
|
|
|
|
docker tag "${IMAGE_NAME}:${TAG}" "$FULL_IMAGE"
|
|
echo "$DOCKER_PASSWORD" | docker login "$REGISTRY_HOST" -u "$DOCKER_USERNAME" --password-stdin
|
|
docker push "$FULL_IMAGE"
|
|
docker logout "$REGISTRY_HOST"
|