Skip to content
This repository was archived by the owner on Oct 24, 2022. It is now read-only.

Commit 1674fe0

Browse files
feat(cd): Create action to deploy
Action will deploy new code to production when there's a non major version bump
1 parent c78d7ae commit 1674fe0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy on tag
2+
3+
on:
4+
push:
5+
tags:
6+
"v*"
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Get major of current tag and previous tag
17+
id: vars
18+
run: |
19+
git fetch -a
20+
echo ::set-output name=current_major::$(git tag --sort "-committerdate" | cut -d$'\n' -f1 | cut -d. -f1)
21+
echo ::set-output name=previous_major::$(git tag --sort "-committerdate" | cut -d$'\n' -f2 | cut -d. -f1)
22+
23+
- name: SSH Commands
24+
if: ${{ steps.vars.outputs.current_major == steps.vars.outputs.previous_major }}
25+
uses: appleboy/ssh-action@v0.1.4
26+
env:
27+
PROCESS_PATH: ${{ secrets.CD_PROCESS_PATH }}
28+
PROCESS_ID: ${{ secrets.CD_PROCESS_ID }}
29+
GITHUB_REF: ${{ env.GITHUB_REF }}
30+
with:
31+
host: ${{ secrets.CD_HOST }}
32+
username: ${{ secrets.CD_USERNAME }}
33+
key: ${{ secrets.CD_SECRET_KEY }}
34+
script_stop: true
35+
envs: PROCESS_PATH, PROCESS_ID, GITHUB_REF
36+
script: |
37+
source ~/.profile
38+
source ~/.nvm/nvm.sh
39+
cd $PROCESS_PATH
40+
pip install --user -U pipenv
41+
git pull origin main --tags
42+
git checkout $GITHUB_REF
43+
pipenv install
44+
pm2 restart $PROCESS_ID -s

0 commit comments

Comments
 (0)