Skip to content

Commit 987ec9b

Browse files
authored
Merge ssh key config
1 parent e123c11 commit 987ec9b

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v5
13+
- name: ssh keys
14+
env:
15+
SSH_PRIVATE_KEY: ${{ secrets.REMOTE_PRIVATE_KEY }}
16+
shell: bash
17+
run: |
18+
mkdir -p ~/.ssh
19+
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
20+
chmod 600 ~/.ssh/id_rsa
21+
ssh-keyscan -H ${{ secrets.REMOTE_HOST_1 }} >> ~/.ssh/known_hosts
22+
ssh-keyscan -H ${{ secrets.REMOTE_HOST_2 }} >> ~/.ssh/known_hosts
1323
- name: rsync prod1
1424
uses: burnett01/rsync-deployments@7.1.0
1525
with:
@@ -19,15 +29,6 @@ jobs:
1929
remote_port: ${{ secrets.REMOTE_PORT }}
2030
remote_user: ${{ secrets.REMOTE_USER }}
2131
remote_key: ${{ secrets.REMOTE_PRIVATE_KEY }}
22-
- name: ssh prod1
23-
env:
24-
SSH_PRIVATE_KEY: ${{ secrets.REMOTE_PRIVATE_KEY }}
25-
shell: bash
26-
run: |
27-
mkdir -p ~/.ssh
28-
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
29-
chmod 600 ~/.ssh/id_rsa
30-
ssh-keyscan -H ${{ secrets.REMOTE_HOST_1 }} >> ~/.ssh/known_hosts
3132
- name: docker prod1
3233
run: |
3334
ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST_1 }} "cd ${{ secrets.REMOTE_PATH }}; docker compose pull; docker compose up -d --build --force-recreate"
@@ -40,15 +41,6 @@ jobs:
4041
remote_port: ${{ secrets.REMOTE_PORT }}
4142
remote_user: ${{ secrets.REMOTE_USER }}
4243
remote_key: ${{ secrets.REMOTE_PRIVATE_KEY }}
43-
- name: ssh prod2
44-
env:
45-
SSH_PRIVATE_KEY: ${{ secrets.REMOTE_PRIVATE_KEY }}
46-
shell: bash
47-
run: |
48-
mkdir -p ~/.ssh
49-
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
50-
chmod 600 ~/.ssh/id_rsa
51-
ssh-keyscan -H ${{ secrets.REMOTE_HOST_2 }} >> ~/.ssh/known_hosts
5244
- name: docker prod2
5345
run: |
5446
ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST_2 }} "cd ${{ secrets.REMOTE_PATH }}; docker compose pull; docker compose up -d --build --force-recreate"

0 commit comments

Comments
 (0)