deploy to server #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: deploy to server | |
| on: workflow_dispatch | |
| jobs: | |
| check-admin: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: check-auth | |
| run: | | |
| ADMIN_USERS="Canoobi blnpurple" | |
| if [[ ! " $ADMIN_USERS " =~ " ${{ github.actor }} " ]]; then | |
| echo "You are not authorized to run this workflow." | |
| exit 1 | |
| fi | |
| pull-repo: | |
| needs: check-admin | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Pull from Git | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.NAS_HOST }} | |
| username: ${{ secrets.NAS_USER }} | |
| password: ${{ secrets.NAS_SSH_KEY }} | |
| script: | | |
| cd ${{ secrets.REPO_PATH }} | |
| /opt/bin/git config --global --add safe.directory ${{ secrets.REPO_PATH }} | |
| /opt/bin/git pull https://${{ secrets.PULL_GITHUB_USER }}:${{ secrets.PULL_GITHUB_TOKEN }}@github.com/Software-Engineering-I-HWR/GourmetGuide.git | |
| restart-containers: | |
| needs: pull-repo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Restart containers | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.NAS_HOST }} | |
| username: ${{ secrets.NAS_USER }} | |
| password: ${{ secrets.NAS_SSH_KEY }} | |
| script: | | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-DB-API | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-DB-API-Login | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-Login-API | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-PDF-API | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-ImageUpload-API | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-Global-API | |
| echo "${{ secrets.NAS_SSH_KEY }}" | sudo -S /usr/local/bin/docker restart GourmetGuide-UI |