2024-04-19 15:12:54 +03:00
name : Full building alt images
on :
push :
tags :
2024-11-11 18:58:45 +03:00
- '*_*'
2024-04-19 15:12:54 +03:00
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 }}
2024-11-11 18:58:45 +03:00
- name : Set repo for c10f2 (Temporary)
if : ${{ contains(github.ref_name, 'c10f2') }}
run : |
echo "event tag=${{ github.ref_name }}"
echo "10.4.0.3 update.altsp.su" >> /etc/hosts
echo "cat /etc/hosts"
cat /etc/hosts
2024-04-19 15:12:54 +03:00
- name : Update apt
uses : actions/init-alt-env@v1
- name : Install requires
run : |
2024-11-11 16:37:04 +03:00
echo "apt-get install -y python3-module-tomli python3-module-jinja2 python3-module-yaml python3-module-requests podman buildah jq curl"
apt-get install -y python3-module-tomli python3-module-jinja2 python3-module-yaml python3-module-requests podman buildah jq curl
2024-11-05 16:54:11 +03:00
echo "apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-ppc qemu-user-static-binfmt-riscv qemu-user-static-binfmt-loongarch"
apt-get install -y qemu-user-static-binfmt-aarch64 qemu-user-static-binfmt-arm qemu-user-static-binfmt-ppc qemu-user-static-binfmt-riscv qemu-user-static-binfmt-loongarch
2024-04-19 15:12:54 +03:00
- name : Check out current repo
uses : actions/checkout@v4
2024-11-11 12:27:59 +03:00
- name : Parse target branch and tag from events context, save to env
2024-04-19 15:12:54 +03:00
env :
2024-11-11 12:27:59 +03:00
EV : ${{ toJson(gitea.event) }}
2024-04-19 15:12:54 +03:00
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)
2024-11-11 12:27:59 +03:00
echo "ORG=$org" >> ${GITHUB_ENV}
2024-04-19 15:12:54 +03:00
echo "ORG=$org"
- name : Login podman gitea
run : |
echo "podman login ${{ env.URL }}"
2024-11-11 12:27:59 +03:00
podman login --username $P_USER --password $P_PASS ${{ env.URL }}
2024-04-19 15:12:54 +03:00
env :
P_USER : ${{ secrets.PODMAN_USER }}
P_PASS : ${{ secrets.PODMAN_PASS }}
- name : Run building script
id : build-script
run : |
2024-11-11 18:58:45 +03:00
build_args="-b $BR -o $ORG --skip-images alt/distroless-devel"
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64"; else arches="--arches amd64 386 arm64"; fi
if [[ "$ORG" == "k8s" ]]; then build_args="$build_args --overwrite-organization $ORG-$BR --package-versions {\"k8s/kube-apiserver\":\"1.31\",\"k8s/kube-scheduler\":\"1.31\",\"k8s/kube-controller-manager\":\"1.31\",\"k8s/kube-proxy\":\"1.31\",\"k8s/coredns\":\"1.11.3\",\"k8s/kubelet\":\"1.31\"}"; fi
echo "build.py $build_args $arches"
${{ gitea.workspace }}/build.py $build_args $arches
2024-04-19 15:12:54 +03:00
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
2024-11-11 12:27:59 +03:00
echo "tag $tagname is deleted"
2024-04-19 15:12:54 +03:00
env :
T : ${{ secrets.TOKEN }}
BR : ${{ env.BRANCH }}
URL : ${{ gitea.server_url }}
REPO : ${{ env.REPO }}
EV : ${{ toJson(gitea.event) }}
test-process :
needs : build-process
2024-11-11 12:27:59 +03:00
if : ${{ needs.build-process.outputs.buildres == 'success' && needs.build-process.outputs.org != 'k8s' }}
2024-04-19 15:12:54 +03:00
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 }}