Skip to content

Commit 534167b

Browse files
authored
Merge pull request #11 from Plant-Tracer/6-automate-site-deployment
6 automate site deployment: all set
2 parents ee077ca + 2e3f896 commit 534167b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/deploy.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://stackoverflow.com/questions/60710209/trigger-github-actions-only-when-pr-is-merged
2+
name: Deploy
3+
concurrency: production
4+
5+
on:
6+
pull_request:
7+
types: [closed]
8+
workflow_dispatch:
9+
10+
env:
11+
SSH_USER: planttracer
12+
APP_HOST: planttracer.com
13+
DEPLOY_DIR: planttracer.com/web-static
14+
15+
jobs:
16+
if-merged:
17+
if: github.event.pull_request.merged == true
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: "Deploy to $APP_HOST $DEPLOY_DIR"
24+
run: |
25+
echo APP_HOST: $APP_HOST DEPLOY_DIR: $DEPLOY_DIR
26+
eval $(ssh-agent)
27+
base64 -d <<< "${{ secrets.PT_SSH_BASE64 }}" | ssh-add -
28+
ssh-add -l
29+
ssh -o StrictHostKeyChecking=no -o GlobalKnownHostsFile=etc/known_hosts $SSH_USER@$APP_HOST "python3 --version; hostname; pwd; cd $DEPLOY_DIR; ls -l"
30+
ssh -o StrictHostKeyChecking=no -o GlobalKnownHostsFile=etc/known_hosts $SSH_USER@$APP_HOST "cd $DEPLOY_DIR; git checkout main && git pull --recurse-submodules"

0 commit comments

Comments
 (0)