Deploy #29
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag to deploy' | |
| required: false | |
| default: '' | |
| workflow_run: | |
| workflows: [Build] | |
| types: | |
| - completed | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| jobs: | |
| Deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get latest version | |
| if: ${{ ! contains(inputs.version, '.') }} | |
| id: latest | |
| uses: gregziegan/[email protected] | |
| - name: Resolve version | |
| id: version | |
| uses: haya14busa/action-cond@v1 | |
| with: | |
| cond: ${{ ! contains(inputs.version, '.') }} | |
| if_true: ${{ steps.latest.outputs.name }} | |
| if_false: ${{ inputs.version }} | |
| - uses: chrnorm/deployment-action@releases/v1 | |
| name: Create deployment for ${{ steps.version.outputs.value }} | |
| id: deployment | |
| with: | |
| token: ${{ secrets.PAT }} | |
| description: ${{ steps.version.outputs.value }} | |
| environment: production | |
| - name: Upload release ${{ steps.version.outputs.value }} to server | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| port: 22 | |
| script: | | |
| cd /srv | |
| wget wget https://github.com/jamiefdhurst/blog/releases/download/${{ steps.version.outputs.value }}/blog-${{ steps.version.outputs.value }}.zip | |
| unzip blog-${{ steps.version.outputs.value }}.zip -d blog-${{ steps.version.outputs.value }}/ | |
| rm blog | |
| rm blog-*.zip | |
| ln -s blog-${{ steps.version.outputs.value }} blog | |
| service nginx reload | |
| - name: Update deployment status (success) | |
| if: success() | |
| uses: chrnorm/deployment-status@v2 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| environment-url: https://jamiehurst.co.uk | |
| state: success | |
| deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
| - name: Update deployment status (failure) | |
| if: failure() | |
| uses: chrnorm/deployment-status@v2 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| environment-url: https://jamiehurst.co.uk | |
| state: failure | |
| deployment-id: ${{ steps.deployment.outputs.deployment_id }} |