Add auto build and auto deploy support
This commit is contained in:
parent
666c4bee89
commit
de77fd622f
3 changed files with 42 additions and 15 deletions
BIN
7zas
Normal file
BIN
7zas
Normal file
Binary file not shown.
14
Dockerfile
14
Dockerfile
|
@ -1,14 +0,0 @@
|
||||||
FROM alpine
|
|
||||||
|
|
||||||
ENV HOME=/app \
|
|
||||||
NODE_ENV=production
|
|
||||||
|
|
||||||
WORKDIR $HOME
|
|
||||||
|
|
||||||
COPY package.json $HOME/
|
|
||||||
|
|
||||||
RUN apk update && apk upgrade && apk add nodejs npm && npm install --production
|
|
||||||
|
|
||||||
COPY api $HOME/api
|
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
|
43
appveyor.yml
43
appveyor.yml
|
@ -1,5 +1,6 @@
|
||||||
# version format
|
# version format
|
||||||
version: '{build}'
|
version: '{build}'
|
||||||
|
deploy: on
|
||||||
|
|
||||||
# branches to build
|
# branches to build
|
||||||
branches:
|
branches:
|
||||||
|
@ -23,10 +24,50 @@ environment:
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- sh: |
|
- sh: |
|
||||||
|
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
|
||||||
chown -R node:node /appveyor/projects
|
chown -R node:node /appveyor/projects
|
||||||
npm install
|
npm install
|
||||||
npm list --all
|
npm list --all
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- sh: |
|
- sh: |
|
||||||
npm run test:linux
|
npm run test:linux
|
||||||
|
|
||||||
|
on_success:
|
||||||
|
- sh: |
|
||||||
|
apk add curl jq
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Finished installling curl and jq"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CURR_VER=$(cat package.json | jq -r .version)
|
||||||
|
echo "Checking https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases for version v${CURR_VER}"
|
||||||
|
curl -s -X GET -H "Authorization: token $deploytoken" https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases | grep -o "\"name\"\:\"v${CURR_VER}\"" > /dev/null
|
||||||
|
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
echo "Release already exists, nothing to do.";
|
||||||
|
else
|
||||||
|
./7zas a -mx9 "${CURR_VER}_build-sc.7z" package.json index.mjs api
|
||||||
|
echo "Creating release on gitea"
|
||||||
|
RELEASE_RESULT=$(curl \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token $deploytoken" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases \
|
||||||
|
-d "{\"tag_name\":\"v${CURR_VER}\",\"name\":\"v${CURR_VER}\",\"body\":\"Automatic release from Appveyor from ${APPVEYOR_REPO_COMMIT} :\n\n${APPVEYOR_REPO_COMMIT_MESSAGE}\"}")
|
||||||
|
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 $deploytoken" \
|
||||||
|
-F "attachment=@${CURR_VER}_build-sc.7z" \
|
||||||
|
https://git.nfp.is/api/v1/repos/$APPVEYOR_REPO_NAME/releases/$RELEASE_ID/assets
|
||||||
|
|
||||||
|
echo "Deplying to production"
|
||||||
|
curl -X POST http://192.168.93.50:4010/update/service-upload
|
||||||
|
fi
|
||||||
|
|
||||||
|
# on build failure
|
||||||
|
on_failure:
|
||||||
|
- sh: echo on_failure
|
||||||
|
|
Loading…
Reference in a new issue