-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (34 loc) · 1.46 KB
/
npm-grunt.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Next CI/CD in Develop branch
on:
push:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add env
run: echo "${{ secrets.NEXT_LOCAL_ENV }}" > ./.env.local
- name: Docker build
run: DOCKER_BUILDKIT=1 docker build -t ${{ secrets.DOCKER_REPO }}/${{ secrets.DOCKER_IMAGE }} .
- 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.DOCKER_REPO }}/${{ secrets.DOCKER_IMAGE }}
- name: Deploy to dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
script: |
docker stop frontend
docker rm frontend
docker rmi ${{ secrets.DOCKER_REPO }}/${{ secrets.DOCKER_IMAGE }}
docker pull ${{ secrets.DOCKER_REPO }}/${{ secrets.DOCKER_IMAGE }}
docker run -dp 3000:3000 --name=frontend ${{ secrets.DOCKER_REPO }}/${{ secrets.DOCKER_IMAGE }}