Skip to content

Commit faa4f4c

Browse files
committed
test ci action
1 parent d3cddbe commit faa4f4c

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
workflow_dispatch:
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
name: Deploy website to server
11+
env:
12+
MACHINE_USER_NAME: kenneth
13+
MACHINE_NAME: helian
14+
steps:
15+
- name: Setup Tailscale
16+
uses: tailscale/github-action@v3
17+
with:
18+
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
19+
- name: Add SSH key
20+
env:
21+
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
22+
run: |
23+
mkdir -p ~/.ssh
24+
MACHINE_IP="$(tailscale ip -6 $MACHINE)"
25+
ssh-keyscan $MACHINE_IP >> ~/.ssh/known_hosts
26+
printf "%s" "$SSH_KEY" > ~/.ssh/key
27+
chmod 600 ~/.ssh/key
28+
- name: Deploy website
29+
run: |
30+
MACHINE_IP=$(tailscale ip -6 $MACHINE)
31+
ssh -i ~/.ssh/key kenneth@MACHINE_IP <<EOF
32+
cd /opt/website
33+
git pull
34+
docker build -t website .
35+
docker stop website-container
36+
docker rm website-container
37+
docker run --name=website-container --restart=always --publish 5432:80 --detach website
38+
EOF
39+

0 commit comments

Comments
 (0)