Skip to content

Commit

Permalink
Merge pull request #20 from bescka/workflows
Browse files Browse the repository at this point in the history
deployment: workflow_config
  • Loading branch information
BraunRudolf authored Aug 1, 2024
2 parents 8b275e2 + 1f56455 commit 7ae2254
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/deploy_on_push.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Deploy on Push

on:
push:
branches:
Expand All @@ -9,24 +11,27 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install SSH keys
run: |
echo "Installing SSH keys..."
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
install -m 600 -D /dev/null ~/.ssh/id_ed25519
echo "${{ secrets.EC2_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
echo "SSH keys installed."
- name: Connect and pull latest code
run: |
echo "Pulling latest code from remote repository..."
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull"
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull"
echo "Code pulled successfully."
- name: Manage Docker Compose on Remote Server
run: |
echo "Managing Docker Compose on remote server..."
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
echo "Stopping and removing Docker containers..."
cd ${{ secrets.WORK_DIR }}
docker-compose down
Expand All @@ -44,4 +49,3 @@ jobs:
echo "Cleaning up SSH keys..."
rm -rf ~/.ssh
echo "SSH keys cleaned up."

0 comments on commit 7ae2254

Please sign in to comment.