-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (82 loc) · 2.73 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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: robinraju/[email protected]
with:
tag: ${{ steps.version.outputs.value }}
fileName: "blog-*.zip"
tarBall: false
zipBall: false
extract: false
- 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
source: blog-${{ steps.version.outputs.value }}.zip
target: /srv/
- 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
unzip blog-${{ steps.version.outputs.value }}.zip -o -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 }}