Create CI_CD.yml #1
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: CI/CD counter app | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
#First we will see the application build or not , then we will deploy in EC2 | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build the docker_compose | |
run: docker-compose up -d --build | |
- name: Buid the application | |
run: docker-compose exec -T counter_app npm run build | |
Deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Deploy in EC2 | |
env: | |
PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} | |
HOSTNAME : ${{ secrets.HOST }} | |
USER_NAME : ${{ secrets.USERNAME }} | |
run: | | |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |
#Now we have got the access of EC2 and we will start the deploy . | |
pwd | |
' |