refactor(web): mobile responsive updates #181
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check-changes: | |
runs-on: ubuntu-latest | |
environment: Production | |
outputs: | |
changes: ${{ steps.check_changes.outputs.changes }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Check for changes in server | |
id: check_changes | |
run: | | |
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^apps/server/' && echo "changes=true" >> $GITHUB_OUTPUT || echo "changes=false" >> $GITHUB_OUTPUT | |
deploy: | |
runs-on: ubuntu-latest | |
environment: Production | |
needs: check-changes | |
if: needs.check-changes.outputs.changes == 'true' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Build and push Docker image | |
run: | | |
docker compose build | |
docker tag brunoroh/bolhadev-chat:latest ${{ vars.DOCKER_REPO}}/bolhadev-chat:latest | |
docker tag brunoroh/bolhadev-nginx:latest ${{ vars.DOCKER_REPO}}/bolhadev-nginx:latest | |
docker login -u ${{ vars.DOCKER_USERNAME }} -p ${{secrets.DOCKER_TOKEN}} | |
docker push ${{ vars.DOCKER_REPO}}/bolhadev-chat:latest | |
docker push ${{ vars.DOCKER_REPO}}/bolhadev-nginx:latest | |
- name: SSH into EC2 instance and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
sudo docker pull ${{ vars.DOCKER_REPO }}/bolhadev-chat:latest | |
sudo docker pull ${{ vars.DOCKER_REPO }}/bolhadev-nginx:latest | |
sudo docker stop bolhadev-nginx || true | |
sudo docker stop bolhadev-chat || true | |
sudo docker rm bolhadev-nginx || true | |
sudo docker rm bolhadev-chat || true | |
sudo docker run -d -p "127.0.0.1:4000:4000" -p "127.0.0.1:4001:4001" --name bolhadev-chat --restart unless-stopped --network internal ${{ vars.DOCKER_REPO }}/bolhadev-chat:latest | |
sudo docker run -d -p 80:80 -p 443:443 \ | |
--name bolhadev-nginx \ | |
-v /var/www/certbot:/var/www/certbot \ | |
-v /etc/letsencrypt/ssl/fullchain.pem:/etc/nginx/ssl/fullchain.pem \ | |
-v /etc/letsencrypt/ssl/privkey.pem:/etc/nginx/ssl/privkey.pem \ | |
--network internal \ | |
${{ vars.DOCKER_REPO }}/bolhadev-nginx:latest | |
docker image prune -f |