v1.0.7 #9
Workflow file for this run
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 on Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to Server | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| port: 224 | |
| debug: true | |
| envs: GITHUB_TOKEN,GITHUB_REPOSITORY,TAG_NAME | |
| script: | | |
| set -e | |
| echo "Starting deployment..." | |
| pkill -f "ssh-application/[s]erver" || true | |
| mkdir -p ~/ssh-application | |
| cd ~/ssh-application | |
| echo "Downloading release..." | |
| curl -L -f -o ssh-app-linux-amd64.tar.gz \ | |
| -H "Authorization: token ${GITHUB_TOKEN}" \ | |
| "https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/ssh-app-linux-amd64.tar.gz" | |
| echo "Extracting..." | |
| tar -xzvf ssh-app-linux-amd64.tar.gz | |
| chmod +x linux-amd64/server | |
| mv linux-amd64/server ./server | |
| rm -rf linux-amd64 ssh-app-linux-amd64.tar.gz | |
| sudo setcap cap_net_bind_service=+ep ./server | |
| echo "Starting server..." | |
| nohup ./server > server.log 2>&1 < /dev/null & | |
| sleep 2 | |
| echo "Deployment Done!" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| TAG_NAME: ${{ github.event.release.tag_name }} |