-
Notifications
You must be signed in to change notification settings - Fork 6
85 lines (73 loc) ยท 2.58 KB
/
backend-dev-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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: deploy
on:
push:
branches:
- release/backend
jobs:
docker-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build for asciiDoc
run: ./gradlew bootjar
- name: Build with Gradle
run: ./gradlew bootjar
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: woowacarffeine/backend
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./backend/Dockerfile
push: true
platforms: linux/arm64
tags: woowacarffeine/backend-dev:latest
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: self-hosted
if: ${{ needs.docker-build.result == 'success' }}
needs: [ docker-build ]
steps:
- name: run docker
run: |
sudo docker pull woowacarffeine/backend-dev:latest
sudo docker stop backend-dev || true
sudo docker container prune -f
sudo docker run -d -p 8081:8080 -p 8088:8088 \
-e "SPRING_PROFILE=dev" \
-e "ENCRYPT_KEY=${{secrets.JASYPT_KEY}}" \
-e "DATABASE_USERNAME=${{secrets.DATABASE_USERNAME}}" \
-e "DATABASE_PASSWORD=${{secrets.DATABASE_PASSWORD}}" \
-e "REPLICA_DATABASE_USERNAME=${{secrets.REPLICA_DB_USER_NAME}}" \
-e "REPLICA_DATABASE_PASSWORD=${{secrets.REPLICA_DB_USER_PASSWORD}}" \
-e "SLACK_WEBHOOK_URL=${{secrets.SLACK_WEBHOOK_URL}}" \
--name backend-dev \
woowacarffeine/backend-dev:latest
sudo docker image prune -a -f