Deploy to Private Instance #5
This file contains 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 Private Instance | |
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: | | |
docker pull ghcr.io/jamiefdhurst/journal:${{ steps.version.outputs.value }} | |
docker rmi journal:latest | |
docker tag ghcr.io/jamiefdhurst/journal:${{ steps.version.outputs.value }} journal:latest | |
service supervisor stop | |
service supervisor start | |
- name: Update deployment status (success) | |
if: success() | |
uses: chrnorm/deployment-status@v2 | |
with: | |
token: ${{ secrets.PAT }} | |
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 }} | |
state: failure | |
deployment-id: ${{ steps.deployment.outputs.deployment_id }} |