New Version 1.1.3 #25
Workflow file for this run
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: Build Test Deploy and Publish Production Project In AWS | |
on: | |
push: | |
branches: | |
- release/* | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- release/* | |
jobs: | |
build_and_test: | |
name: Build_And_Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Install dependencies | |
run: npm install --force | |
continue-on-error: false | |
- name: Build | |
run: npm run build | |
continue-on-error: false | |
- name: Test | |
run: npm run test | |
continue-on-error: false | |
sonarcloud: | |
needs: build_and_test | |
name: SonarCloud | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Install dependencies | |
run: npm install --force | |
continue-on-error: false | |
- name: Test and Generate Report Coverage | |
run: npm run test:coverage | |
continue-on-error: false | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
deploy_prod: | |
needs: sonarcloud | |
name: Production Build Deploy and Publish Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
env: | |
DOCKER_CLI_AGGREGATE: 1 | |
run: | | |
docker-compose -f docker-compose.prod.yml build | |
continue-on-error: false | |
- name: Push Docker image to Docker Hub | |
env: | |
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_CLI_AGGREGATE: 1 | |
run: | | |
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker push ${{ secrets.DOCKER_IMAGE_PROD }} | |
continue-on-error: false | |
- name: Execute SSH Commands into EC2 | |
env: | |
EC2_HOST: ${{ secrets.EC2_HOST }} | |
EC2_USERNAME: ${{ secrets.EC2_USERNAME }} | |
AWS_SSH_KEY: ${{ secrets.AWS_SSH_KEY }} | |
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
port: 22 | |
script: | | |
./scripts/dp-react.prod.sh |