Skip to content

Commit 2eeab5b

Browse files
committed
ci: refactor GitHub Actions key management
- Add steps to set public and private keys in GitHub Actions environment - Replace inline public key assignment with environment variable reference - Remove redundant steps for setting private key in GitHub Actions environment Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 977b74a commit 2eeab5b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

.github/workflows/ssh-server.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,28 @@ jobs:
4545
- name: Checkout code
4646
uses: actions/checkout@v4
4747

48+
- name: add public key to env
49+
run: |
50+
echo "PUBLIC_KEY<<EOF" >> $GITHUB_ENV
51+
cat testdata/.ssh/id_rsa.pub >> $GITHUB_ENV
52+
echo "EOF" >> $GITHUB_ENV
53+
echo "======= public key ========="
54+
cat testdata/.ssh/id_rsa.pub
55+
echo "============================"
56+
echo "PRIVATE_KEY<<EOF" >> $GITHUB_ENV
57+
cat testdata/.ssh/id_rsa >> $GITHUB_ENV
58+
echo "EOF" >> $GITHUB_ENV
59+
echo "======= private key ========="
60+
cat testdata/.ssh/id_rsa
61+
echo "============================"
62+
4863
- name: create new ssh server
4964
run: |
5065
docker run -d \
5166
--name=openssh-server \
5267
--hostname=openssh-server \
5368
-p 2223:2222 \
54-
-e PUBLIC_KEY=$(cat testdata/.ssh/id_rsa.pub) \
69+
-e PUBLIC_KEY="${{ env.PUBLIC_KEY }}" \
5570
-e SUDO_ACCESS=false \
5671
-e PASSWORD_ACCESS=true \
5772
-e USER_PASSWORD=password \
@@ -62,9 +77,6 @@ jobs:
6277
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
6378
cat ip.txt >> $GITHUB_ENV
6479
echo "EOF" >> $GITHUB_ENV
65-
echo "PRIVATE_KEY<<EOF" >> $GITHUB_ENV
66-
cat testdata/.ssh/id_rsa >> $GITHUB_ENV
67-
echo "EOF" >> $GITHUB_ENV
6880
echo "======= container ip address ========="
6981
cat ip.txt
7082
echo "======================================"

0 commit comments

Comments
 (0)