Skip to content

Instantly share code, notes, and snippets.

@saviour123
Created August 30, 2021 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saviour123/21b776929e543f28a60d6f46742cfe40 to your computer and use it in GitHub Desktop.
Save saviour123/21b776929e543f28a60d6f46742cfe40 to your computer and use it in GitHub Desktop.
Github Actions Deploy Strategy for SSH/LINUX Server Approach
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 ubuntu@ec2-13-244-229-135.af-south-1.compute.amazonaws.com -v 'cd /tmp && ls -l' -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment