2024-04-19 15:12:54 +03:00
name : Full building alt images
on :
push :
tags :
- 'sisyphus_*'
jobs :
build-process :
runs-on : alt-sisyphus
outputs :
branch : ${{ env.BRANCH }}
org : ${{ env.ORG }}
url : ${{ env.URL }}
repo : ${{ env.REPO }}
buildres : ${{ steps.build-script.outcome }}
steps :
- name : Check workspace
run : |
repourl=$(echo $GU | cut -d '/' -f 3)
echo "URL=$repourl" >> ${GITHUB_ENV}
echo $repourl
reponame=$(echo $GR | cut -d '/' -f 1)
echo "REPO=$reponame" >> ${GITHUB_ENV}
echo $reponame
env :
GU : ${{ gitea.server_url }}
GR : ${{ gitea.repository }}
- name : Update apt
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"
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl
echo "apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-ppc"
apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-ppc
- name : Check out current repo
uses : actions/checkout@v4
- name : Parse target branch and tag from events context, save to env
env :
EV : ${{ toJson(gitea.event) }}
run : |
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1 >> ${GITHUB_ENV}
org=$(echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 2)
echo "ORG=$org" >> ${GITHUB_ENV}
echo "ORG=$org"
- name : Login podman gitea
run : |
echo "podman login ${{ env.URL }}"
podman login --username $P_USER --password $P_PASS ${{ env.URL }}
env :
P_USER : ${{ secrets.PODMAN_USER }}
P_PASS : ${{ secrets.PODMAN_PASS }}
- name : Run 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
echo "build.py $build_args"
${{ gitea.workspace }}/build.py $build_args
env :
ORG : ${{ env.ORG }}
BR : ${{ env.BRANCH }}
continue-on-error : true
- name : Send notification if build crashed
if : ${{ steps.build-script.outcome != 'success' }}
run : |
2024-04-23 13:35:41 +03:00
issueid=1
body="Building images finish with some errors."
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
echo "notification about test error is sent to issue $issueid"
2024-04-19 15:12:54 +03:00
env :
T : ${{ secrets.TOKEN }}
BR : ${{ env.BRANCH }}
URL : ${{ gitea.server_url }}
REPO : ${{ env.REPO }}
- name : Delete event tag
run : |
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
echo "tag $tagname is deleted"
env :
T : ${{ secrets.TOKEN }}
BR : ${{ env.BRANCH }}
URL : ${{ gitea.server_url }}
REPO : ${{ env.REPO }}
EV : ${{ toJson(gitea.event) }}
test-process :
needs : build-process
if : ${{ needs.build-process.outputs.buildres == 'success' }}
runs-on : alt-sisyphus
steps :
- name : Update apt
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"
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
id : test-script
continue-on-error : true
run : |
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $WS
cat haserr.log >> ${GITHUB_ENV}
echo "test process finished"
env :
BR : ${{ needs.build-process.outputs.branch }}
ORG : ${{ needs.build-process.outputs.org }}
URL : ${{ needs.build-process.outputs.url }}
REPO : ${{ needs.build-process.outputs.repo }}
WS : ${{ gitea.workspace }}
- name : Send notification if test crashed
if : ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
run : |
2024-04-23 13:35:41 +03:00
issueid=1
errors=$(cat errors.log)
body="Testing images finish with some errors. $errors"
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
echo "notification about test error is sent to issue $issueid"
2024-04-19 15:12:54 +03:00
env :
T : ${{ secrets.TOKEN }}
BR : ${{ needs.build-process.outputs.branch }}
URL : ${{ gitea.server_url }}
REPO : ${{ needs.build-process.outputs.repo }}