Deploy to PRODUCTION #87
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
on: | |
workflow_dispatch: | |
name: Deploy to PRODUCTION | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
services: | |
plataforma-sabia-redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
plataforma-sabia-mysql: | |
image: mysql | |
env: | |
MYSQL_ROOT_PASSWORD: '' | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_DATABASE: sabia_testing | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Setup API and run tests | |
run: | | |
cd packages/api | |
cp .env.testing .env | |
npm install | |
npm run test | |
npm run migration:refresh -- --seed | |
- name: Setup WEB and run tests | |
run: | | |
cd packages/web | |
npm install | |
npm run jest:ci | |
- name: Run Cypress tests | |
uses: cypress-io/github-action@v2 | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
with: | |
command: npm run test:e2e:run | |
record: true | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push ADMIN docker image | |
id: docker_build_admin | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: ./packages/admin/docker/Dockerfile | |
tags: plataformasabia/admin:${{ github.sha }} | |
- name: Build and push WEB docker image | |
id: docker_build_web | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: ./packages/web/docker/Dockerfile | |
tags: plataformasabia/web:${{ github.sha }} | |
- name: Build and push API docker image | |
id: docker_build_api | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: ./packages/api/docker/Dockerfile | |
tags: plataformasabia/api:${{ github.sha }} | |
- name: Deploy to PRODUCTION | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEPLOY_HOST_VPS_1 }} | |
username: ${{ secrets.DEPLOY_USER_VPS_1 }} | |
key: ${{ secrets.DEPLOY_KEY_VPS_1 }} | |
port: ${{ secrets.DEPLOY_PORT_VPS_1 }} | |
script: ./deploy-image-to-vps.sh ${{ github.sha }} |