Merge pull request #53 from VentionCapstone/feature/114_wishlist #24
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: VENTION BOOKING CI (DEV) | |
on: | |
push: | |
branches: ['develop'] | |
env: | |
DOCKERHUB_IMAGE_NAME: vention-booking | |
DOCKER_CONTAINER_NAME: backend-server | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build, tag, and push docker image | |
run: | | |
docker build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/${{env.DOCKERHUB_IMAGE_NAME}}:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{env.DOCKERHUB_IMAGE_NAME}}:latest | |
- name: Rename docker compose config file | |
run: mv docker-compose.ci.yml docker-compose.yml | |
- name: Copy docker compose config file to EC2 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST_DEV }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: ${{ secrets.EC2_PORT }} | |
source: 'docker-compose.yml' | |
target: /home/ec2-user | |
- name: Login to EC2 instance | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST_DEV }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
port: ${{ secrets.EC2_PORT }} | |
script: | | |
docker-compose down | |
docker-compose rm -f ${{env.DOCKER_CONTAINER_NAME}} | |
docker-compose pull ${{env.DOCKER_CONTAINER_NAME}} | |
docker-compose up -d ${{env.DOCKER_CONTAINER_NAME}} |