Last active
October 13, 2022 10:35
-
-
Save Farhandroid/cf1988ea552d4ccb55bcec017fabdc62 to your computer and use it in GitHub Desktop.
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.HOSTNAME }} | |
USER_NAME : ${{ secrets.USER_NAME }} | |
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 . | |
cd /home/ubuntu/CounterApp && | |
git checkout master && | |
git fetch --all && | |
git reset --hard origin/master && | |
git pull origin master && | |
docker-compose -f docker-compose.prod.yml up -d --build | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment