From 751d20178da2626e64fb6246c5f6b7c7d59c22ee Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 11 Mar 2023 00:51:29 +0100 Subject: [PATCH] Discord pipeline notifications modcheck? --- .gitlab-ci.yml | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2c59b8..b399a77 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,32 +1,50 @@ +stages: + - deploy + - notification + update-ip: stage: .post image: python:3.10.8-slim-buster rules: - - if: '$NEW_IP != ""' + - if: '$NEW_IP != ""' allow_failure: true when: manual before_script: - - apt-get update - - apt-get install -y python3-pip - - python --version - - pip install -r requirements.txt + - apt-get update + - apt-get install -y python3-pip + - python --version + - pip install -r requirements.txt script: - - python cloudflare-updater.py $CF_API_TOKEN $NEW_IP + - python cloudflare-updater.py $CF_API_TOKEN $NEW_IP deploy-site: stage: deploy rules: - if: $CI_COMMIT_BRANCH == "main" before_script: - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - - eval $(ssh-agent -s) - - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - - chmod 644 ~/.ssh/known_hosts + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts script: - - 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" - \ No newline at end of file + - 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" + +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