generated from amattu2/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (56 loc) · 1.88 KB
/
api-deployment.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
name: API Deployment
on:
push:
tags:
- "v*"
paths-ignore:
- ".vscode/**"
- ".github/**"
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'placeholder-app' }}
permissions:
deployments: write
steps:
# Setup Local SSH Key
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PROD_SSH_PK }}
known_hosts: 'temporary-value-ignore'
# Add Server To Known Hosts
- name: Setup Known Hosts
run: ssh-keyscan -H ${{ secrets.PROD_SSH_HOST }} >> ~/.ssh/known_hosts
# Create GitHub Deployment
- uses: chrnorm/deployment-action@v2
name: Create Deployment
id: deployment
with:
token: '${{ github.token }}'
environment-url: https://api.placeholder.app
environment: production
description: Production environment deployment
auto-inactive: true
# Update Production
- name: Update Production
run: |
ssh ${{ secrets.PROD_SSH_USER }}@${{ secrets.PROD_SSH_HOST }} "
cd /var/www/backend && git pull origin master
make build_linux && sudo service API restart"
- name: Update Deployment Status (Success)
if: success()
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'success'
- name: Update Deployment Status (Fail)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'