diff --git a/.gitea/workflows/wf.yaml b/.gitea/workflows/wf.yaml index fded87a..fbc8a2e 100644 --- a/.gitea/workflows/wf.yaml +++ b/.gitea/workflows/wf.yaml @@ -5,8 +5,15 @@ on: - '*_*/*' jobs: - Building_process: + build_process: runs-on: alt-latest + outputs: + branch: ${{ env.BRANCH }} + image: ${{ env.IMAGE }} + url: ${{ env.URL }} + repo: ${{ env.REPO }} + buildres: ${{ steps.build_script.outcome }} + test: ${{ env.TEST }} steps: - name: Check workspace run: | @@ -23,12 +30,12 @@ jobs: apt-get update -y && apt-get install -y apt rpm - name: Install requires run: | - echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl jq" - apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl jq + echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq" + apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq 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@v3 + uses: https://gitea.com/actions/checkout@v4 - name: Login podman gitea run: | echo "podman login ${{ env.URL }}" @@ -49,10 +56,10 @@ jobs: echo "IMAGE=$localimage" >> ${GITHUB_ENV} echo "IMAGE=$localimage" - name: Get test for image - run: | - cat ${{ gitea.workspace }}/org/$IM/test >> ${GITHUB_ENV} - env: + testscript=$(cat ${{ gitea.workspace }}/org/$IM/test) + echo "TEST=$testscript">> ${GITHUB_ENV} + env: IM: ${{ env.IMAGE }} BR: ${{ env.BRANCH }} - name: Run building script @@ -64,46 +71,66 @@ jobs: IM: ${{ env.IMAGE }} BR: ${{ env.BRANCH }} continue-on-error: true + test_process: + if: ${{ jobs.build_process.env.BUILDRES == 'success' }} + needs: build_process + runs-on: alt-latest + outputs: + testres: ${{ steps.test_script.outcome }} + steps: + - name: Update apt + run: | + echo "apt-get update -y && apt-get install -y apt rpm" + apt-get update -y && apt-get install -y apt rpm + - name: Install requires + run: | + echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah" + apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah + 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: Run test - id: images_test - if: ${{ steps.build_script.outcome == 'success' }} + id: test_script continue-on-error: true - uses: fmidev/podman-run-action@v1 + uses: https://gitea.basealt.ru/actions/podman-run-action@v2 with: - image: ${{ env.url }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.BRANCH }} - shell: bash - options: --rm --log-level trace - run: | - echo "${{ env.TEST }}" - ${{ env.TEST }} + image: ${{ needs.build_process.outputs.url }}/${{ needs.build_process.outputs.repo }}/${{ needs.build_process.outputs.image }}:${{ needs.build_process.outputs.branch }} + options: --rm + run: ${{ needs.build_process.outputs.test }} + finish_process: + needs: [ build_process, test_process ] + runs-on: alt-latest + steps: + - name: Update apt + run: | + echo "apt-get update -y && apt-get install -y apt rpm" + apt-get update -y && apt-get install -y apt rpm + - name: Update apt + run: | + echo "apt-get install -y curl jq" + apt-get install -y curl jq - name: Delete event tag run: | tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g") - echo "https://$URL/api/v1/repos/$REPO/gitea-image-forge/tags/$tagname?token=$T" curl -X 'DELETE' "https://$URL/api/v1/repos/$REPO/gitea-image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s echo "tag $BR_$IM is deleted" env: T: ${{ secrets.TOKEN }} - URL: ${{ env.URL }} - REPO: ${{ env.REPO }} - IM: ${{ env.IMAGE }} - BR: ${{ env.BRANCH }} + URL: ${{ needs.build_process.outputs.url }} + REPO: ${{ needs.build_process.outputs.repo }} + IM: ${{ needs.build_process.outputs.image}} + BR: ${{ needs.build_process.outputs.branch }} EV: ${{ toJson(gitea.event) }} continue-on-error: true - name: Send comment to issue for notification run: | - echo "https://$URL/api/v1/repos/$REPO/gitea-image-forge/issues?state=all&type=issues&page=1&limit=1&token=$T" issueid=$(curl -X 'GET' "https://$URL/api/v1/repos/$REPO/gitea-image-forge/issues?state=all&type=issues&page=1&limit=1&token=$T" -H 'accept: application/json' -s | jq '.[].number' -r) - if [[ ${{ steps.build_script.outcome == 'success' && steps.images_test.outcome == 'success' }} ]]; then body="Building of image $IM for branch $BR finished success"; else body="Testing of image $IM for branch $BR is failed"; fi - if [[ ${{ steps.build_script.outcome == 'failure' }} ]]; then body="Building of image $IM for branch $BR is failed"; fi - echo "https://$URL/api/v1/repos/$REPO/gitea-image-forge/issues/$issueid/comments?token=$T" + if [[ ${ needs.build_process.outputs.buildres }} = "success" ]] && [[ ${{ needs.test_process.outputs.testres }} = "success" ]]; then body="Building of image $IM for branch $BR finished success"; else body="Testing of image $IM for branch $BR is failed"; fi + if [[ ${{ needs.build_process.outputs.buildres }} != 'success' ]]; then body="Building of image $IM for branch $BR is failed"; fi curl -X 'POST' "https://$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 is sent" env: T: ${{ secrets.TOKEN }} - URL: ${{ env.URL }} - REPO: ${{ env.REPO }} - IM: ${{ env.IMAGE }} - BR: ${{ env.BRANCH }} - - name: Check status - run: echo "This job's status is ${{ job.status }}" + URL: ${{ needs.build_process.outputs.url }} + REPO: ${{ needs.build_process.outputs.repo }} + IM: ${{ needs.build_process.outputs.image}} + BR: ${{ needs.build_process.outputs.image}} diff --git a/.gitea/workflows/wf_test.yaml b/.gitea/workflows/wf_test.yaml index 107e070..bc42adb 100644 --- a/.gitea/workflows/wf_test.yaml +++ b/.gitea/workflows/wf_test.yaml @@ -1,23 +1,23 @@ -name: Test event wf +name: Test_wf on: push: tags: - '*' jobs: - Test event: + Test-job: runs-on: alt-latest + env: + TEST: "gitea --version" steps: - name: Update apt run: apt-get update -y && apt-get install -y apt rpm - - name: Install jq - run: apt-get install -y jq - - name: Get event context and parse tag name - env: - EV: ${{ toJson(gitea.event) }} - run: | - echo $EV | jq '.ref' -r | sed 's/refs\/tags\//tag=/g' - echo $EV | jq '.ref' -r | sed 's/refs\/tags\//NEW_TAG=/g' >> ${GITHUB_ENV} - - name: Run script - run: echo "${{ env.NEW_TAG }}" + - name: Install reqs + run: apt-get install -y podman buildah + - name: Podman run + uses: https://gitea.basealt.ru/actions/podman-run-action@v2 + with: + image: gitea.basealt.ru/images_repo/alt/gitea + options: --rm + run: ${{ env.TEST }} - run: echo "This job's status is ${{ job.status }}" diff --git a/org/alt/apache2/test b/org/alt/apache2/test new file mode 100644 index 0000000..fa90eeb --- /dev/null +++ b/org/alt/apache2/test @@ -0,0 +1 @@ +apachectl -v diff --git a/org/alt/gitea/test b/org/alt/gitea/test index c4aef8f..605c725 100644 --- a/org/alt/gitea/test +++ b/org/alt/gitea/test @@ -1 +1 @@ -TEST="gitea --version" +gitea --version diff --git a/org/alt/python/test b/org/alt/python/test index 4fd504a..496ccf3 100644 --- a/org/alt/python/test +++ b/org/alt/python/test @@ -1 +1 @@ -TEST="pyhon3 --help" +python3 --help