Finish moving the workflow for nfp_moe
This commit is contained in:
parent
4b9d6b6522
commit
edfa250dde
2 changed files with 46 additions and 5 deletions
|
@ -10,18 +10,59 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Check for new release
|
- name: Check for new release
|
||||||
run: |
|
run: |
|
||||||
|
checkExitCode() {
|
||||||
|
if [ $1 -ne 0 ] ; then
|
||||||
|
echo "Command failed with error code $1"
|
||||||
|
exit $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cd ${{ gitea.job }}
|
cd ${{ gitea.job }}
|
||||||
CURR_VER="$(cat package.json | jq -r .name)_v$(cat package.json | jq -r .version)"
|
CURR_VER="$(cat package.json | jq -r .name)_v$(cat package.json | jq -r .version)"
|
||||||
CURR_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"
|
CURR_NAME="$(cat package.json | jq -r .name) v$(cat package.json | jq -r .version)"
|
||||||
|
|
||||||
echo "Checking https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases for name ${CURR_NAME}"
|
echo "Checking https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases for name ${CURR_NAME}"
|
||||||
curl -s -X GET -H "Authorization: token ${{ secrets.deploytoken }}" https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases | grep -o "\"name\"\:\"${CURR_NAME}\"" > /dev/null
|
curl -s -X GET -H "Authorization: token ${{ secrets.deploytoken }}" https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases | grep -o "\"name\"\:\"${CURR_NAME}\"" > /dev/null
|
||||||
|
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
echo "Skipping ${{ gitea.job }} since $CURR_NAME already exists";
|
echo "Skipping ${{ gitea.job }} since $CURR_NAME already exists";
|
||||||
gh run cancel ${{ gitea.run_id }}
|
exit 0;
|
||||||
gh run watch ${{ gitea.run_id }}
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "There is new release"
|
mv package.json fuck-you-npm-package.json
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
mv build-package.json package.json
|
||||||
|
npm install && npm run build
|
||||||
|
|
||||||
|
checkExitCode $?
|
||||||
|
|
||||||
|
mv package.json build-package.json
|
||||||
|
mv fuck-you-npm-package.json package.json
|
||||||
|
|
||||||
|
../7zas a -xr!*.xcf -mx9 "${CURR_VER}_build-sc.7z" package.json index.mjs api base public
|
||||||
|
echo "Creating release on gitea"
|
||||||
|
RELEASE_RESULT=$(curl \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.deploytoken }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases \
|
||||||
|
-d "{\"tag_name\":\"${CURR_VER}\",\"name\":\"${CURR_NAME}\",\"body\":\"Automatic release from Appveyor from ${{ gitea.sha }} :\n\n${{ gitea.event.head_commit.message }}\"}")
|
||||||
|
|
||||||
|
checkExitCode $?
|
||||||
|
|
||||||
|
RELEASE_ID=$(echo $RELEASE_RESULT | jq -r .id)
|
||||||
|
echo "Adding ${CURR_VER}_build-sc.7z to release ${RELEASE_ID}"
|
||||||
|
|
||||||
|
curl \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.deploytoken }}" \
|
||||||
|
-F "attachment=@${CURR_VER}_build-sc.7z" \
|
||||||
|
https://git.nfp.is/api/v1/repos/${{ gitea.repository }}/releases/$RELEASE_ID/assets
|
||||||
|
|
||||||
|
checkExitCode $?
|
||||||
|
|
||||||
|
MAN_PORT=$(cat package.json | jq -r .port)
|
||||||
|
MAN_NAME=$(cat package.json | jq -r .name)
|
||||||
|
|
||||||
|
echo "Deplying to production"
|
||||||
|
echo "curl -X POST http://192.168.93.50:$MAN_PORT/update/$MAN_NAME"
|
||||||
|
curl -X POST http://192.168.93.50:$MAN_PORT/update/$MAN_NAME
|
Loading…
Reference in a new issue