Skip to content

Deploy in Production new Features (#40) #30

Deploy in Production new Features (#40)

Deploy in Production new Features (#40) #30

name: Build Test Deploy and Publish Production Project In AWS
on:
push:
branches:
- main
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
deploy_prod:
needs: build_and_test
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