-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (65 loc) · 2.02 KB
/
dev-cicd.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
64
65
66
67
68
69
70
71
72
73
74
name: cicd for development
on:
push:
branches: [ "dev" ]
jobs:
build:
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Copy application.yml
env:
OCCUPY_DEPLOY: ${{ secrets.OCCUPY_DEPLOY }}
OCCUPY_DB: ${{ secrets.OCCUPY_DB }}
OCCUPY_AWS: ${{ secrets.OCCUPY_AWS }}
run: |
cd ./src/main/resources
touch ./application.yml
echo "$OCCUPY_DEPLOY" > ./application.yml
touch ./application-db.yml
echo "$OCCUPY_DB" > ./application-db.yml
touch ./application-aws.yml
echo "$OCCUPY_AWS" > ./application-aws.yml
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: clean build
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build & push to dockerhub
run: |
docker build -f Dockerfile -t modernfarmer/farmus-spring .
docker push modernfarmer/farmus-spring
deploy:
needs: build
runs-on: ubuntu-latest
environment: dev
steps:
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-prod
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
sudo docker pull modernfarmer/farmus-spring
cd docker-compose
bash deploy.sh
docker image prune -f