Skip to content

Commit bb28fe3

Browse files
committed
feat: add deploy GitHub action
1 parent ef7ee4d commit bb28fe3

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎.github/workflows/deploy-main.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: deploy-main
13+
cancel-in-progress: false
14+
15+
jobs:
16+
deploy:
17+
name: Deploy to production server
18+
runs-on: ubuntu-latest
19+
environment: production
20+
steps:
21+
- name: SSH key setup
22+
run: |
23+
mkdir -p ~/.ssh
24+
echo "${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}" > ~/.ssh/gha_private_key
25+
chmod 600 ~/.ssh/gha_private_key
26+
- name: SSH fetch commit and setup
27+
env:
28+
DEPLOY_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
29+
DEPLOY_USER: ${{ secrets.DEPLOY_SERVER_USER }}
30+
DEPLOY_PORT: ${{ vars.DEPLOY_SERVER_PORT || 22 }}
31+
DEPLOY_DIRECTORY: ${{ vars.DEPLOY_DIRECTORY }}
32+
run: |
33+
ssh -i ~/.ssh/gha_private_key -p ${{ env.DEPLOY_PORT }} -o StrictHostKeyChecking=accept-new ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} << 'ENDSSH'
34+
cd ${{ env.DEPLOY_DIRECTORY }}
35+
git fetch origin main
36+
git checkout main
37+
git pull --ff origin main
38+
task rebuild
39+
ENDSSH

0 commit comments

Comments
 (0)