Discord pipeline notifications modcheck?

This commit is contained in:
Firq 2023-03-11 00:51:29 +01:00
parent 358cd5ee9a
commit 751d20178d
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20

View file

@ -1,32 +1,50 @@
stages:
- deploy
- notification
update-ip: update-ip:
stage: .post stage: .post
image: python:3.10.8-slim-buster image: python:3.10.8-slim-buster
rules: rules:
- if: '$NEW_IP != ""' - if: '$NEW_IP != ""'
allow_failure: true allow_failure: true
when: manual when: manual
before_script: before_script:
- apt-get update - apt-get update
- apt-get install -y python3-pip - apt-get install -y python3-pip
- python --version - python --version
- pip install -r requirements.txt - pip install -r requirements.txt
script: script:
- python cloudflare-updater.py $CF_API_TOKEN $NEW_IP - python cloudflare-updater.py $CF_API_TOKEN $NEW_IP
deploy-site: deploy-site:
stage: deploy stage: deploy
rules: rules:
- if: $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_BRANCH == "main"
before_script: before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s) - eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- chmod 700 ~/.ssh - chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts
script: script:
- echo "Connecting to proxmox machine" - echo "Connecting to proxmox machine"
- ssh $DEPLOY_USER@$DEPLOY_HOST -o StrictHostKeyChecking=no IdentitiesOnly=yes "screen -X -S website-firq-npx kill; rm -r -f public/*; cd build; git reset --hard; git pull; rm -r -f node_modules; npm install; npm run build; cp -R public ~; cd ~; screen -S website-firq-npx -dm npx serve public/ -p 9000" - ssh $DEPLOY_USER@$DEPLOY_HOST -o StrictHostKeyChecking=no IdentitiesOnly=yes "screen -X -S website-firq-npx kill; rm -r -f public/*; cd build; git reset --hard; git pull; rm -r -f node_modules; npm install; npm run build; cp -R public ~; cd ~; screen -S website-firq-npx -dm npx serve public/ -p 9000"
success_notification:
stage: notification
script:
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
when: on_success
failure_notification:
stage: notification
script:
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL
when: on_failure