-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (106 loc) · 3.97 KB
/
union.yaml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#두개를 하나로 합쳐서 빌드 후 차트 배포까지 하는중
name: Build and Deploy to GKE For Argo CD
on:
push:
branches:
- release
env:
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_EMAIL: ${{ secrets.GKE_EMAIL }}
GITHUB_SHA: ${{ github.sha }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
REGISTRY_HOSTNAME: gcr.io
IMAGE: jsvill-fullstack
IMAGE_TAG: latest
jobs:
#job을 여러개로 나누면, job마다 checkout을 중복으로 해줘야함해서 하나로함
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: release
- name: JDK 16 설치
uses: actions/setup-java@v3
with:
java-version: '16'
distribution: 'corretto'
- name: application.yaml 파일 생성
run: touch ./src/main/resources/application.yaml
- name: application.yaml에 작성
run: echo "${{ secrets.APPLICATION }}" | base64 -d > ./src/main/resources/application.yaml
- name: application.yaml 내용 표시
run: cat ./src/main/resources/application.yaml
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GKE_KEY }}
# Setup gcloud CLI
- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GKE_EMAIL }}
service_account_key: ${{ secrets.GKE_KEY }}
- name: Install gke-gcloud-auth-plugin
run: gcloud components install gke-gcloud-auth-plugin
- name: Enable gke-gcloud-auth-plugin
run: echo "USE_GKE_GCLOUD_AUTH_PLUGIN=True" >> $GITHUB_ENV
- name: Get GKE credentials
run: gcloud container clusters get-credentials $GKE_CLUSTER --zone $GKE_ZONE --project $GKE_PROJECT
- name: Configure Docker
run: gcloud auth configure-docker
# Build the Docker image
- name: Build
run: |-
docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$IMAGE_TAG" \
--build-arg IMAGE_TAG="$IMAGE_TAG" \
--build-arg GITHUB_REF="$GITHUB_REF" .
# Push the Docker image to Google Container Registry
- name: Publish
run: docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:$IMAGE_TAG
bump-version-and-release-charts:
needs: setup-build-publish-deploy
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
new-version: ${{ steps.bump-version.outputs.new-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: release
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "Sean-creative"
- name: Bump chart version
id: bump-version
run: |
CHART_DIR=charts/jsvill-chart
VERSION=$(awk '/^version: /{print $2}' $CHART_DIR/Chart.yaml)
NEW_VERSION=$(echo $VERSION | awk -F. '{++$NF}1' | tr ' ' '.')
echo "Current VERSION: $VERSION"
echo "New VERSION: $NEW_VERSION"
sed -i "s/^version: $VERSION/version: $NEW_VERSION/" $CHART_DIR/Chart.yaml
echo "::set-output name=new-version::$NEW_VERSION"
git add $CHART_DIR/Chart.yaml
git commit -m "Bump chart version to $NEW_VERSION"
git push origin HEAD
- name: Install Helm
uses: azure/setup-helm@v3
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.CR_TOKEN }}"