* MOD: workflow tests
Some checks failed
Build and push / check and test (push) Failing after 6s
Build and push / build_and_push (push) Failing after 2s

Signed-off-by: Uwe Hermann <uh@uleenucks.de>
This commit is contained in:
2024-01-21 13:25:09 +01:00
parent b6f1f947b4
commit 38c2b5c2f6
2 changed files with 100 additions and 8 deletions

View File

@@ -21,11 +21,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to docker
run: mkdir -p $HOME/.docker && cp config.json $HOME/.docker/config.json
- name: Install docker
run: curl -fsSL https://get.docker.com | sh
- name: Install parallel
run: apt install parallel -y
- name: Build docker container
run: ./build-all.sh && exit 0
# - name: Login to docker
# run: mkdir -p $HOME/.docker && cp config.json $HOME/.docker/config.json
# - name: Install docker
# run: curl -fsSL https://get.docker.com | sh
# - name: Install parallel
# run: apt install parallel -y
# - name: Build docker container
# run: ./build-all.sh && exit 0
- name: Use kaniko image
image: gcr.io/kaniko-project/executor:debug
run: cp config.json /kaniko/.docker/config.json && cp plugin.sh /kaniko/plugin.sh && /kaniko/plugin.sh

89
plugin.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
#!/bin/bash
set -e
set -o pipefail
SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
REPO_URL="${REPO_URL:-uleenucks}"
DOCKERFILESPATH="${HOME}/closed/dockerfiles"
ERRORS="$(pwd)/errors"
build_and_push_kaniko(){
base=$1
suite=$2
build_dir=$3
echo "Building ${REPO_URL}/${base}:${suite} for context ${build_dir}"
/kaniko/executor \
--dockerfile="${build_dir}" \
--destination="${REPO_URL}/${base}:${suite}" \
--force \
--cleanup \
|| return 1
# on successful build, push the image
echo " --- "
echo "Successfully built and pushed ${base}:${suite} with context ${build_dir}"
echo " --- "
}
dofile() {
f=$1
image=${f%Dockerfile}
base=${image%%\/*}
build_dir=$(dirname "$f")
suite=${build_dir##*\/}
if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then
suite=latest
fi
{
$SCRIPT build_and_push_kaniko "${base}" "${suite}" "${build_dir}"
} || {
# add to errors
echo "${base}:${suite}" >> "$ERRORS"
}
echo
echo
}
main(){
# get the dockerfiles
IFS=$'\n'
files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) )
unset IFS
# build all dockerfiles
echo "Running in parallel with ${JOBS} jobs."
"$SCRIPT" dofile "{1}" ::: "${files[@]}"
if [[ ! -f $ERRORS ]]; then
echo "No errors, hooray!"
else
echo "[ERROR] Some images did not build correctly, see below." >&2
echo "These images failed: $(cat "$ERRORS")" >&2
exit 1
fi
}
run(){
args=$@
f=$1
if [[ "$f" == "" ]]; then
main "$args"
else
$args
fi
}
run $@
/kaniko/executor \
--dockerfile="Dockerfile1" \
--destination="registry.io/image1:tag1" \
--cleanup
/kaniko/executor --dockerfile="Dockerfile2" --destination="registry.io/image2:tag2"