change branches p*/c* workflow for new struct

This commit is contained in:
Nadezhda Fedorova 2024-05-21 17:51:25 +03:00
parent 28c0fc03cf
commit 9c460b363e
2 changed files with 67 additions and 41 deletions

View File

@ -6,53 +6,70 @@
#$4 - ${{ needs.build-process.outputs.repo }}
#$5 - ${{ gitea.workspace }}
BR=${1:-"p10"}
ORG=${2:-"base"}
URL=${3:-"gitea.basealt.ru"}
REPO=${4:-"alt"}
WS=${5:-"image-forge"}
errors=''
haserr=false
for IM in $(ls $5/org/$2/ | xargs)
for IM in $(ls $WS/org/$ORG/ | xargs)
do
echo "image=$IM"
if test -f $5/org/$2/$IM/test
then
test=$(cat $5/org/$2/$IM/test)
else test=''
fi
imgpath="$REPO/$BR/$IM:$BR"
command=''
testpath="$WS/org/$ORG/$IM/test.yaml"
if test -f $testpath
then
entrypoint=''
testep=$(cat $testpath | yq '.entrypoint' -r 2> /dev/null)
if [[ $testep != '' ]]; then entrypoint="--entrypoint=\"$testep\""; fi
echo "test script=$test"
imgpath="$2/$IM:$1"
if [[ $2 == 'k8s' ]]
then imgpath="$2-$1/$IM:latest"
testcom=$(cat $testpath | yq '.command' -r 2> /dev/null)
if [[ $testcom != '' ]]
then command="podman run --rm $entrypoint $URL/$imgpath -c \"$testcom\""
else echo "test command is not found"
fi
else echo "test file is not found"
fi
command="echo empty_command"
if [[ $test != '' ]]; then
command="podman run --rm --entrypoint=\"/bin/sh\" $3/$imgpath -c \"$test\""
else
if [[ $IM = 'distroless-true' ]]; then
command="podman run --rm $3/$imgpath \"true\""
fi
if [[ $IM = 'distroless-gotop' ]]; then
command="podman run --rm $3/$imgpath \"--version\""
fi
if [[ $IM = 'flannel-cni-plugin' ]]; then
command="podman run --rm $3/$imgpath \"/flannel\""
fi
if [[ $IM = 'pause' ]]; then
command="podman run --rm $3/$imgpath \"/pause\" \"-v\""
fi
fi
echo $command
echo "result test command: $command"
eval $command 2>$IM.log || haserr=true
echo "podman rmi --all"
podman rmi --all
if [ "$haserr" = false ]
then
echo "start change tag for $IM"
if [[ $ORG != 'base' ]]
then
package=$(podman images --filter reference=$URL/$imgpath --format='{{ json .Labels }}' | jq '."org.opencontainers.image.title"' -r 2> /dev/null)
if [[ $package != '' ]]
then
tag=$(podman run --rm --entrypoint="/bin/sh" $URL/$imgpath -c "rpm -qa --qf \"%{VERSION}\n\" $package" 2> /dev/null)
else
echo "not found package name in images labels"
fi
else
then tag=$(date +"%Y%m%d")
fi
if [ "$haserr" = true ]
then
if [[ $tag != '' ]]
then
skopeo copy -a docker://$URL/$imgpath:$BR docker://$URL/$imgpath:$tag
scopeo delete docker://$URL/$imgpath:$BR
echo "tag is updated"
else echo "new tag is empty and is not sent to repository"
fi
else
if [[ $(cat $IM.log) != '' ]]
then errors="TEST ERROR OF IMAGE $IM: $(cat $IM.log); $errors"
else errors="TEST ERROR OF IMAGE $IM: test returned empty error, but exit status was nozero; $errors"
fi
fi
fi
echo "podman rmi --all"
podman rmi --all
fi
haserr=false
done

View File

@ -2,7 +2,10 @@ name: Full building alt images
on:
push:
tags:
- '*10*_*'
- '*_*'
tags-ignore:
- '*_k8s'
- 'sisyphus_*'
jobs:
build-process:
@ -58,11 +61,10 @@ jobs:
env:
P_USER: ${{ secrets.PODMAN_USER }}
P_PASS: ${{ secrets.PODMAN_PASS }}
- name: Run building script
- name: Run standart building script
id: build-script
run: |
build_args="-b $BR -o $ORG --skip-images alt/distroless-devel"
if [[ $ORG == 'k8s' ]]; then build_args="$build_args --tags tags.toml --overwrite-organization $ORG-$BR --skip-images k8s/kube-apiserver k8s/kube-controller-manager k8s/kube-proxy k8s/kube-scheduler"; fi
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --overwrite-organization $BR --registry $URL/$BR"
echo "build.py $build_args"
${{ gitea.workspace }}/build.py $build_args
env:
@ -101,11 +103,18 @@ jobs:
uses: actions/init-alt-env@v1
- name: Install requires
run: |
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl"
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl"
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl
- name: Check out current repo
uses: https://gitea.com/actions/checkout@v4
- name: Test
- name: Login podman gitea
run: |
echo "podman login ${{ env.URL }}"
podman login --username $P_USER --password $P_PASS ${{ needs.build-process.outputs.url }}
env:
P_USER: ${{ secrets.PODMAN_USER }}
P_PASS: ${{ secrets.PODMAN_PASS }}
- name: Test images and update tags
id: test-script
continue-on-error: true
run: |