Skip to content

Commit

Permalink
Deploy to stage server with Github Action
Browse files Browse the repository at this point in the history
  • Loading branch information
softcat477 committed Oct 30, 2023
1 parent 989200d commit 3fcecfb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cd_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to staging Server
on:
push:
branches:
- "main"

concurrency:
group: staging
cancel-in-progress: true

jobs:
deploy-staging:
runs-on: ubuntu-latest
steps:
- name: Checkout to source code
uses: actions/checkout@v3
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Stop docker swarm and cleanup services
run: |
ssh -J ${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST1 }},${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST2 }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd /cantus-ultimus && sudo docker compose stop"
- name: Log git branch we're on
run: |
ssh -J ${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST1 }},${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST2 }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd /cantus-ultimus && sudo git branch --all -v"
- name: Fetch on dev branch
run: |
ssh -J ${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST1 }},${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST2 }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd /cantus-ultimus && sudo git fetch origin main && sudo git merge origin/main"
- name: Build docker images
run: |
ssh -J ${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST1 }},${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST2 }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd /cantus-ultimus && sudo docker compose build"
- name: Start the service
run: |
ssh -J ${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST1 }},${{ secrets.PROXY_USERNAME }}@${{ secrets.PROXY_HOST2 }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd /cantus-ultimus && sudo docker compose up -d"

0 comments on commit 3fcecfb

Please sign in to comment.