Skip to content

Merge pull request #91 from Funssion-SWM/develop #9

Merge pull request #91 from Funssion-SWM/develop

Merge pull request #91 from Funssion-SWM/develop #9

Workflow file for this run

name: Next CI/CD in Develop branch
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add env
run: echo "${{ secrets.NEXT_LOCAL_ENV_PROD_TEMP }}" > ./.env.local
- name: Docker build
run: DOCKER_BUILDKIT=1 docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_PROD_TEMP }} .
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_PROD_TEMP }}
- name: Deploy to dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD_TEMP }}
username: ec2-user
key: ${{ secrets.NEW_PRIVATE_KEY }}
script: |
docker stop frontend
docker rm frontend
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_PROD_TEMP }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_PROD_TEMP }}
docker run -dp 3000:3000 --name=frontend ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPO_PROD_TEMP }}