-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (37 loc) · 1.24 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
name: build-push-deploy
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
run: docker buildx build \
--build-arg JWT_SECRET=${{ secrets.JWT_SECRET }} \
--build-arg MONGO_URI=${{ secrets.MONGO_URI }} \
--build-arg PORT=${{ vars.PORT }} \
-t kingitsolutionsteam/nawwa-test:${{ github.sha }} .
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image to Docker Hub
run: docker push kingitsolutionsteam/nawwa-test:${{ github.sha }}
deploy:
runs-on: nawwa-runner
needs: build-and-push
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Pull Docker image
run: sudo docker pull kingitsolutionsteam/nawwa-test:${{ github.sha }}
- name: Deploy Docker image
run: sudo docker run -d -p ${{ vars.PORT }}:9005 kingitsolutionsteam/nawwa-test:${{ github.sha }}