Skip to content

Commit

Permalink
feat: cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
a2cd committed Jan 15, 2024
1 parent a9e0fec commit 18660a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ jobs:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
KEY_FILE: a2cd.key # 不能用~/.ssh/a2cd.key作为value
HOST_KEY: a2cd # 不能用~/.ssh/a2cd.key作为value
run: |
mkdir -p ~/.ssh/ && echo "$SSH_PRIVATE_KEY" > ~/.ssh/$KEY_FILE && chmod 600 ~/.ssh/$KEY_FILE
mkdir -p ~/.ssh/ && echo "$SSH_PRIVATE_KEY" > ~/.ssh/$HOST_KEY.pri.key && chmod 600 ~/.ssh/$HOST_KEY.pri.key
cat >> ~/.ssh/config <<END
Host a2cd
Host $HOST_KEY
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/$KEY_FILE
IdentityFile ~/.ssh/$HOST_KEY.pri.key
StrictHostKeyChecking no
END
- name: Run git pull
Expand All @@ -74,4 +74,7 @@ jobs:
(echo 'git pull retry: 3/3' && git pull origin main) || \
(echo 'git pull failed' && exit 1)"
- name: Run deploy
run: ssh a2cd 'docker-compose pull && docker-compose up -d'
run: |
ssh a2cd "cd /usr/local/repo/rs-hello-world/ && \
docker-compose pull && \
docker-compose up -d"
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
restart: always
environment:
- TZ=Asia/Shanghai
- HELLO=hello
- HELLO=1
networks:
- main

Expand Down

0 comments on commit 18660a0

Please sign in to comment.