fix(deploy): using passphrase for private ssh key #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy App | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
SSH_PRIVATE_KEY: ${{secrets.SSH_KEY}} | |
SERVER_IP: ${{secrets.SERVER_IP}} | |
NODE_OPTIONS: --max-old-space-size=2048 | |
steps: | |
- name: Setup SSH | |
run: | | |
echo 'echo ${{secrets.SSH_PWD}}' > ~/.ssh/passphrase && chmod 700 ~/.ssh/passphrase | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
- run: npm install yarn -g | |
- name: Build React App | |
run: | | |
yarn install | |
yarn build | |
- name: Deploy | |
run: | | |
which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y ) | |
eval $(ssh-agent -s) | |
cat ${{secrets.SSH_KEY}} | tr -d '\r' | DISPLAY=None SSH_ASKPASS=~/.ssh/passphrase ssh-add - | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
scp -r build/* root@$SERVER_IP:/var/www/html/fantasy.simoen.tech/_work/edd-APP/edd-APP/build |