Created
August 30, 2021 05:10
-
-
Save saviour123/21b776929e543f28a60d6f46742cfe40 to your computer and use it in GitHub Desktop.
Github Actions Deploy Strategy for SSH/LINUX Server Approach
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: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: 'echo "$KA_KEY" > key.pem' | |
shell: bash | |
env: | |
SSH_KEY: ${{secrets.KA_KEY}} | |
- run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_PRIVATE_KEY" > ../private.key | |
sudo chmod 600 ../private.key | |
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | |
shell: bash | |
env: | |
SSH_PRIVATE_KEY: ${{secrets.KA_KEY}} | |
SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}} | |
SSH_KEY_PATH: ${{ github.workspace }}/../private.key | |
- name: Setup SSH Key | |
run: | | |
cat ../private.key | |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../private.key [email protected] -v 'cd /tmp && ls -l' -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment