From 54ac8d2d5a2c103007a7a98de4ef14f84ffeb798 Mon Sep 17 00:00:00 2001 From: Jason <81298350+Deutscher775@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:45:41 +0200 Subject: [PATCH] adding a revoke option --- .github/workflows/revoke_api_deploy.yaml | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/revoke_api_deploy.yaml diff --git a/.github/workflows/revoke_api_deploy.yaml b/.github/workflows/revoke_api_deploy.yaml new file mode 100644 index 0000000..48c1e77 --- /dev/null +++ b/.github/workflows/revoke_api_deploy.yaml @@ -0,0 +1,48 @@ +name: Undo Astroid API update via Github Actions +on: + release: + types: [unpublished] + +jobs: + stop_api: + runs-on: ubuntu-latest + steps: + - name: API Shutdown + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + password: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + sudo systemctl stop astroidapi + + revoke_changes: + runs-on: ubuntu-latest + needs: stop_api + - name: Revert changes + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + password: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + cd /root/astroid + git reset --hard HEAD + git pull origin main + cp -r /root/astroid/src/astroidapi /root/guildcord/astroidapi + cp -r /root/astroid/src/api.py /root/guildcord/api.py + + deploy_api: + runs-on: ubuntu-latest + needs: [stop_api, revoke_changes] + - name: Deploy API + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + password: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + sudo systemctl start astroidapi \ No newline at end of file