File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments