Skip to content

Commit

Permalink
Fix github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Jul 14, 2024
1 parent 459ed3e commit 7dafad3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy to web server

on:
workflow_run:
workflows: ["Django tests"]
types:
- completed
branches:
- dev

jobs:
deploy_dev:
name: Deploy to dev server
runs-on: ubuntu-latest
environment: deployment
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: install ssh keys
# check this thread to understand why its needed:
# https://stackoverflow.com/a/70447517
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY_DEV }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST_DEV }} > ~/.ssh/known_hosts
- name: connect and pull
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST_DEV }} "./update.sh && exit"
- name: cleanup
run: rm -rf ~/.ssh
26 changes: 3 additions & 23 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,15 @@ on:
workflows: ["Django tests"]
types:
- completed
branches:
- main

jobs:
deploy_dev:
name: Deploy to dev server
runs-on: ubuntu-latest
environment: deployment
if: >
${{ github.event.workflow_run.conclusion == 'success'
&& github.event.workflow_run.head_branch == 'dev' }}
steps:
- name: install ssh keys
# check this thread to understand why its needed:
# https://stackoverflow.com/a/70447517
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY_DEV }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST_DEV }} > ~/.ssh/known_hosts
- name: connect and pull
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST_DEV }} "./update.sh && exit"
- name: cleanup
run: rm -rf ~/.ssh

deploy_prod:
name: Deploy to prod server
runs-on: ubuntu-latest
environment: deployment
if: >
${{ github.event.workflow_run.conclusion == 'success'
&& github.event.workflow_run.head_branch == 'main' }}
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: install ssh keys
# check this thread to understand why its needed:
Expand Down

0 comments on commit 7dafad3

Please sign in to comment.