-
Notifications
You must be signed in to change notification settings - Fork 2
50 lines (40 loc) · 1.67 KB
/
main.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
name: Docker Image CI
on:
push:
branches: [ "release" ]
jobs:
build:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
steps:
- uses: actions/checkout@v3
- name: Login Dockerhub
env:
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- name: make .env
run: |
touch .env
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> .env
echo "${{ secrets.SECRET_ENV}}" >> .env
- name: Builder the Docker image
run: docker build --build-arg NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} -t ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 .
- name: taging
run: docker tag ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2 ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2:latest
- name: Push to Dockerhub
run: docker push ${{secrets.DOCKERHUB_USERNAME}}/ts-react-18-nextjs-14.2:latest
- name: executing remote ssh commands using ssh key
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" > /home/ubuntu/itzip/.env
docker-compose -f /home/ubuntu/itzip/docker-compose.yml down
docker-compose -f /home/ubuntu/itzip/docker-compose.yml pull
docker-compose -f /home/ubuntu/itzip/docker-compose.yml up -d
docker system prune -a -f