forked from images/gitea-image-forge
add notification, fix process
This commit is contained in:
parent
d54807cce9
commit
4250455f66
@ -3,9 +3,6 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- '*_*/*'
|
||||
env:
|
||||
url: gitea.basealt.ru
|
||||
repo: images_repo
|
||||
|
||||
jobs:
|
||||
Building_process:
|
||||
@ -13,7 +10,13 @@ jobs:
|
||||
steps:
|
||||
- name: Check workspace
|
||||
run: |
|
||||
echo "runner = ${{ runner.name }}, gitea_url = ${{ gitea.server_url }}, repository = ${{ gitea.repository }}, owner = ${{ gitea.owner }}"
|
||||
repourl=$(echo $GU | cut -d '/' -f 3)
|
||||
echo "URL=$repourl" >> ${GITHUB_ENV}
|
||||
reponame=$(echo $GR | cut -d '/' -f 1)
|
||||
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
||||
env:
|
||||
GU: ${{ gitea.server_url }}
|
||||
GR: ${{ gitea.repository }}
|
||||
- name: Update apt
|
||||
run: |
|
||||
echo "apt-get update -y && apt-get install -y apt rpm"
|
||||
@ -28,53 +31,79 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
- name: Login podman gitea
|
||||
run: |
|
||||
echo "podman login ${{ env.gitea_url }}"
|
||||
podman login --username $P_USER --password $P_PASS ${{ env.url }}
|
||||
#echo "docker login ${{ env.gitea_url }}"
|
||||
#docker login --username $P_USER --password $P_PASS ${{ env.url }}
|
||||
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: Check files in the repository
|
||||
run: |
|
||||
ls -a ${{ gitea.workspace }}
|
||||
- name: Parse target branch and tag from events context, save to env
|
||||
- name: Parse target branch and tag from events context, save to env
|
||||
env:
|
||||
EV: ${{ toJson(gitea.event) }}
|
||||
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}
|
||||
echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 2
|
||||
localimage=$(echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 2)
|
||||
echo "IMAGE=$localimage" >> ${GITHUB_ENV}
|
||||
echo "IMAGE=$localimage" >> ${GITHUB_ENV}
|
||||
echo "IMAGE=$localimage"
|
||||
- name: Get test for image
|
||||
|
||||
run: |
|
||||
cat ${{ gitea.workspace }}/org/$IM/test >> ${GITHUB_ENV}
|
||||
env:
|
||||
IM: ${{ env.IMAGE }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
- name: Run building script
|
||||
id: build_script
|
||||
run: |
|
||||
echo "build.py -i $IM -b $BR"
|
||||
${{ gitea.workspace }}/build.py -i $IM -b $BR
|
||||
if [[ $BR == 'sisyphus' ]]; then ${{ gitea.workspace }}/build.py -i $IM -b $BR --skip-arches arm; else ${{ gitea.workspace }}/build.py -i $IM -b $BR; fi
|
||||
env:
|
||||
IM: ${{ env.IMAGE }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
- name: Get test
|
||||
run: |
|
||||
cat ${{ gitea.workspace }}/org/$IM/test >> ${GITHUB_ENV}
|
||||
echo "TEST=${{ env.TEST }}"
|
||||
env:
|
||||
IM: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
- name: Run test
|
||||
id: images_test
|
||||
if: ${{ steps.build_script.outcome == 'success' }}
|
||||
continue-on-error: true
|
||||
uses: fmidev/podman-run-action@v1
|
||||
with:
|
||||
image: ${{ env.url }}/${{ env.repo }}/${{ env.IMAGE }}:latest
|
||||
registry: ${{ env.url }}/${{ env.repo }}
|
||||
options: --rm
|
||||
image: ${{ env.url }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ env.BRANCH }}
|
||||
shell: bash
|
||||
options: --rm --log-level trace
|
||||
run: |
|
||||
echo "${{ env.TEST }}"
|
||||
${{ env.TEST }}
|
||||
${{ env.TEST }}
|
||||
- name: Delete event tag
|
||||
run: echo "delete"
|
||||
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 }}
|
||||
T: ${{ secrets.TOKEN }}
|
||||
URL: ${{ env.URL }}
|
||||
REPO: ${{ env.REPO }}
|
||||
IM: ${{ env.IMAGE }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
EV: ${{ toJson(gitea.event) }}
|
||||
continue-on-error: true
|
||||
- name: Send comment to issue for notification
|
||||
run: echo "send"
|
||||
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"
|
||||
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}}
|
||||
- run: echo "This job's status is ${{ job.status }}"
|
||||
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 }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user