Skip to content

Merge pull request #365 from meaningfy-ws/feature/MWB-904 #379

Merge pull request #365 from meaningfy-ws/feature/MWB-904

Merge pull request #365 from meaningfy-ws/feature/MWB-904 #379

name: staging CI/CD pipeline
on:
push:
branches: [ develop ]
# workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-server-action
cancel-in-progress: false
jobs:
deploy_and_build:
name: Build and deploy
runs-on: ubuntu-latest
environment: staging
steps:
- name: Install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
- name: connect, pull and build
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "source ~/.bashrc && cd ${{ secrets.STAGING_WORK_DIR }} && git checkout develop && git pull && make deploy-staging-dotenv-file && make stop-frontend && make build-frontend && make stop-backend && make build-backend && exit"
- name: cleanup unused containers, images, volumes, and networks
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.STAGING_WORK_DIR }} && make cleanup-unused-infra && exit"
- name: cleanup
run: rm -rf ~/.ssh