This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (73 loc) · 3.03 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
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
name: CI/CD using GitHub Actions & Bicep
on:
push:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set yml file
uses: microsoft/variable-substitution@v1
with:
files: src/main/resources/application.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USERNAME }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
app.jwt.secretKey: ${{ secrets.TOKEN_SECRET_KEY }}
app.jwt.accessExpire: ${{ secrets.ACCESS_EXPIRE }}
app.jwt.refreshExpire: ${{ secrets.REFRESH_EXPIRE }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: List build/libs contents
run: ls -la build/libs
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/sodam .
docker push ${{ secrets.DOCKER_USERNAME }}/sodam:latest
- name: Install azd
uses: Azure/[email protected]
- name: Log in with Azure using Service Principal
run: |
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
shell: bash
- name: Install Bicep CLI
run: az bicep install
- name: Validate Bicep file
run: az bicep build --file ./main.bicep
- name: Deploy Azure Infrastructure using Bicep
run: |
az deployment group create \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--template-file ./main.bicep \
--parameters @./parameters.json
- name: Configure Azure App Service to use Docker container
run: |
az webapp config container set \
--name ${{ secrets.AZURE_APP_NAME }} \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--docker-custom-image-name ${{ secrets.DOCKER_USERNAME }}/sodam:latest \
--docker-registry-server-url https://index.docker.io \
--docker-registry-server-user ${{ secrets.DOCKER_USERNAME }} \
--docker-registry-server-password ${{ secrets.DOCKER_PASSWORD }}
- name: Restart Azure App Service
run: |
az webapp restart --name ${{ secrets.AZURE_APP_NAME }} --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }}