Skip to content

Commit 64cc75d

Browse files
chore: build maven in ci/cd
1 parent 93a969f commit 64cc75d

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/maven.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Java CI with Maven
10+
11+
on:
12+
push:
13+
branches: [ "main" ]
14+
pull_request:
15+
branches: [ "main" ]
16+
17+
jobs:
18+
get-secret:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Azure Login
26+
uses: azure/login@v1
27+
with:
28+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
29+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
30+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
31+
32+
- name: Retrieve secret from Key Vault
33+
id: keyvault
34+
uses: azure/CLI@v1
35+
with:
36+
inlineScript: |
37+
SECRET_VALUE=$(az keyvault secret show --name <SECRET_NAME> --vault-name ${{ secrets.KEYVAULT_NAME }} --query value -o tsv)
38+
echo "::add-mask::$SECRET_VALUE"
39+
echo "SECRET_VALUE=$SECRET_VALUE" >> $GITHUB_ENV
40+
- name: Use retrieved secret
41+
run: echo "The secret is successfully retrieved!"
42+
43+
- name: Use SECRET_VALUE in deployment
44+
run: |
45+
./deploy.sh
46+
env:
47+
SECRET_VALUE: ${{ env.SECRET_VALUE }}
48+
build:
49+
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Set up JDK 21
55+
uses: actions/setup-java@v4
56+
with:
57+
java-version: '21'
58+
distribution: 'temurin'
59+
cache: maven
60+
- name: Build with Maven
61+
run: mvn -B package --file pom.xml

0 commit comments

Comments
 (0)