gitea-image-forge/.gitea/workflows/wf_full_p10.yaml
Workflow config file is invalid. Please check your config file: yaml: line 144: could not find expected ':'
2024-09-27 16:55:49 +03:00

196 lines
8.2 KiB
YAML

name: Full building alt images
on:
push:
tags:
- '*_*'
tags-ignore:
- '*_k8s'
- 'sisyphus_*'
jobs:
build-process:
runs-on: alt-p10
outputs:
branch: ${{ env.BRANCH }}
org: ${{ env.ORG }}
url: ${{ env.URL }}
repo: ${{ env.REPO }}
ws: ${{ env.WS }}
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
repows=$(echo $GR | cut -d '/' -f 2)
echo "WS=$repows" >> ${GITHUB_ENV}
echo $repows
env:
GU: ${{ gitea.server_url }}
GR: ${{ gitea.repository }}
- 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
- 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 standart building script
id: build-script
run: |
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --registry $URL/$REPO/$BR -a amd64"
echo "build.py $build_args"
${{ gitea.workspace }}/build.py $build_args
env:
ORG: ${{ env.ORG }}
BR: ${{ env.BRANCH }}
REPO: ${{ env.REPO }}
continue-on-error: true
- name: Send notification if build crashed
if: ${{ steps.build-script.outcome != 'success' }}
run: |
issueid=1
body="Building images finish with some errors."
curl -X 'POST' "$URL/api/v1/repos/$REPO/$GWS/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"
env:
T: ${{ secrets.TOKEN }}
BR: ${{ env.BRANCH }}
URL: ${{ gitea.server_url }}
REPO: ${{ env.REPO }}
GWS: ${{ env.WS }}
- name: Delete event tag
run: |
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/$GWS/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 }}
GWS: ${{ env.WS }}
EV: ${{ toJson(gitea.event) }}
test-process:
needs: build-process
if: ${{ needs.build-process.outputs.buildres == 'success' }}
runs-on: alt-p10
outputs:
testres: ${{ steps.test-script.outcome }}
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 skopeo jq yq curl"
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl
- name: Check out current repo
uses: https://gitea.com/actions/checkout@v4
- name: Login podman gitea
run: |
echo "podman login ${{ needs.build-process.outputs.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: |
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $GWS
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 }}
GWS: ${{ needs.build-process.outputs.ws }}
- name: Send notification if test crashed
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
run: |
issueid=1
d errors=$(cat errors.log)
body="Testing images finish with some errors. $errors"
curl -X 'POST' "$URL/api/v1/repos/$REPO/gitea-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"
env:
T: ${{ secrets.TOKEN }}
BR: ${{ needs.build-process.outputs.branch }}
URL: ${{ gitea.server_url }}
REPO: ${{ needs.build-process.outputs.repo }}
push-process:
needs: [build-process, test-process]
if: ${{ needs.test-process.outputs.testres == 'success' && secrets.PUSH_REPO != '' }}
runs-on: alt-p10
steps:
- name: Update apt
uses: actions/init-alt-env@v1
- name: Install reqier-s
run: |
echo "apt-get install -y skopeo jq"
apt-get install -y skopeo jq
- name: Get branch and tags to push
run: |
echo "PUSH_BRANCH=$BR" >> ${GITHUB_ENV}
images=$()
echo "PUSH_IMAGES=$images" >> ${GITHUB_ENV}
if [[ $BR == 'p10' ]]; then echo "PUSH_TAGS=latest" >> ${GITHUB_ENV}; fi
env:
BR: ${{ needs.build-process.outputs.branch }}
- name: Get branch (only for c*N branches)
if: ${{ contains(github.ref_name, 'c10f2') }}
run: |
newbr=$(skopeo list-tags docker://$URL/$REPO/$BR/base/alt | jq '.Tags.[]' -r 2> /dev/null | sort | grep -m 1 c 2> /dev/null)
echo "PUSH_BRANCH=$newbr" >> ${GITHUB_ENV}
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 }}
- name: Run skopeo action
if: ${{ env.PUSH_BRANCH == needs.build-process.outputs.branch }}
uses: actions/skopeo-copy@v1
with:
source: ${{ needs.build-process.outputs.url }/${{ needs.build-process.outputs.repo }}/${{ needs.build-process.outputs.branch }}/${{ needs.build-process.outputs.org }}
source-proto: docker://
dest: ${{ secrets.PUSH_REPO }}/${{ needs.build-process.outputs.branch }}
dest-proto: docker://
dest-login: ${{ secrets.PUSH_USER }}
dest-pass: ${{ secrets.PUSH_PASS }}
tags: ${{ env.PUSH_TAGS }}
last-ver-tags: true
images: ${{ env.PUSH_IMAGES }}
args: -a