Skip to content

Commit

Permalink
Merge pull request #103 from onecrayon/feature/continuous-deployment
Browse files Browse the repository at this point in the history
Added experimental deployment logic for OpalStack
  • Loading branch information
onecrayon authored Jan 21, 2024
2 parents 4bc6ad5 + 09036a7 commit 9d5c067
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: build-and-test
run-name: Build & Test
name: build-test-deploy
run-name: Build, Test, & Deploy

on:
push:
Expand All @@ -15,6 +15,7 @@ permissions:

jobs:
ci:
name: Build & Test
runs-on: ubuntu-latest

services:
Expand Down Expand Up @@ -57,4 +58,35 @@ jobs:
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
flags: unittests
flags: unittest
cd:
name: Deploy
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: ci
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/deploy.key
chmod 600 ~/.ssh/deploy.key
cat >>~/.ssh/config <<END
Host deploy-server
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/deploy.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
- name: Stop the server
run: ssh deploy-server 'cd ~/apps/api_ashes_live && ./stop'
- name: Check out source
run: ssh deploy-server 'cd ~/apps/api_ashes_live/api.ashes.live && git fetch && git reset --hard origin/main'
- name: Update dependencies & run migrations
run: ssh deploy-server 'cd ~/apps/api_ashes_live && ./update'
- name: Start the server
if: ${{ always() }}
run: ssh deploy-server '~/apps/api_ashes_live && ./start'

0 comments on commit 9d5c067

Please sign in to comment.