-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (62 loc) · 2.12 KB
/
cd-dev.yml
File metadata and controls
73 lines (62 loc) · 2.12 KB
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
name: CI/CD using github actions & docker
on:
push:
branches:
- develop
permissions:
contents: read
jobs:
push_to_registry:
name: Push to aws container registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: make application-prod.yml
if: contains(github.ref, 'develop') || contains(github.ref, 'main')
run: |
cd ./src/main/resources
touch ./application-prod.yml
echo "${{ secrets.YML_PROD }}" > ./application-prod.yml
shell: bash
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
SPRING_PROFILES_ACTIVE: prod
run: ./gradlew clean build --stacktrace
shell: bash
- name: Docker build & push to prod
if: contains(github.ref, 'develop') || contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t kodaero-dev -f ./Dockerfile .
docker tag kodaero-dev:latest ${{ secrets.DOCKER_USER }}/kodaero-dev:latest
docker push ${{ secrets.DOCKER_USER }}/kodaero-dev:latest
pull_from_registry:
name: Connect server ssh and pull from container registry
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: Get Github action IP
id: ip
uses: haythem/public-ip@v1.2
- name: Deploy to prod
if: contains(github.ref, 'develop') || contains(github.ref, 'main')
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_NAME }}
username: ${{ secrets.USER_NAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
script: |
docker pull ${{ secrets.DOCKER_USER }}/kodaero-dev:latest
cd infra
chmod +x ./deploy-dev.sh
sudo ./deploy-dev.sh
docker image prune -f