generated from matheusdoedev/vite-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.82 KB
/
deploy.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Deploy to Amazon ECS
on:
push:
branches: ['master']
env:
CONTAINER_NAME: medical-supplier-manager
CONTAINER_TAG: latest
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v3
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Configuring env production file
run: |
echo "${{ secrets.VITE_INTERVIEW_API_URL }}" > .env.production
ls -la
cat .env.production
- name: Build docker image
run: docker build -t ${{ env.CONTAINER_NAME }} .
- name: Tag image
run: docker tag ${{ env.CONTAINER_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }}:${{ env.CONTAINER_TAG }}
- name: Publish image to docker hub
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }}:${{ env.CONTAINER_TAG }}
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: SSH Deploy
uses: appleboy/ssh-action@master
env:
IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: 22
script: |
sudo docker stop ${{ env.IMAGE_NAME }}
sudo docker rm ${{ env.IMAGE_NAME }}
sudo docker rmi ${{ env.IMAGE_NAME }}
sudo docker pull ${{ env.IMAGE_NAME }}
sudo docker run -d --name ${{ env.CONTAINER_NAME }} -p 80:80 ${{ env.IMAGE_NAME }}
sudo docker exec -it -w /usr/src/app ${{ env.CONTAINER_NAME }} sh
echo "${{ secrets.VITE_INTERVIEW_API_URL }}" > .env