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 <appleboy.tw@gmail.com>
This commit is contained in:
parent
977b74a12d
commit
2eeab5bdba
|
@ -45,13 +45,28 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: add public key to env
|
||||||
|
run: |
|
||||||
|
echo "PUBLIC_KEY<<EOF" >> $GITHUB_ENV
|
||||||
|
cat testdata/.ssh/id_rsa.pub >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
echo "======= public key ========="
|
||||||
|
cat testdata/.ssh/id_rsa.pub
|
||||||
|
echo "============================"
|
||||||
|
echo "PRIVATE_KEY<<EOF" >> $GITHUB_ENV
|
||||||
|
cat testdata/.ssh/id_rsa >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
echo "======= private key ========="
|
||||||
|
cat testdata/.ssh/id_rsa
|
||||||
|
echo "============================"
|
||||||
|
|
||||||
- name: create new ssh server
|
- name: create new ssh server
|
||||||
run: |
|
run: |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name=openssh-server \
|
--name=openssh-server \
|
||||||
--hostname=openssh-server \
|
--hostname=openssh-server \
|
||||||
-p 2223:2222 \
|
-p 2223:2222 \
|
||||||
-e PUBLIC_KEY=$(cat testdata/.ssh/id_rsa.pub) \
|
-e PUBLIC_KEY="${{ env.PUBLIC_KEY }}" \
|
||||||
-e SUDO_ACCESS=false \
|
-e SUDO_ACCESS=false \
|
||||||
-e PASSWORD_ACCESS=true \
|
-e PASSWORD_ACCESS=true \
|
||||||
-e USER_PASSWORD=password \
|
-e USER_PASSWORD=password \
|
||||||
|
@ -62,9 +77,6 @@ jobs:
|
||||||
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
||||||
cat ip.txt >> $GITHUB_ENV
|
cat ip.txt >> $GITHUB_ENV
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
echo "PRIVATE_KEY<<EOF" >> $GITHUB_ENV
|
|
||||||
cat testdata/.ssh/id_rsa >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
echo "======= container ip address ========="
|
echo "======= container ip address ========="
|
||||||
cat ip.txt
|
cat ip.txt
|
||||||
echo "======================================"
|
echo "======================================"
|
||||||
|
|
Loading…
Reference in New Issue