|
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"] |
| 1 | +name: Run Azure Login with OIDC |
| 2 | +on: [push] |
16 | 3 |
|
17 | 4 | permissions: |
18 | 5 | id-token: write |
19 | 6 | contents: read |
20 | | - |
21 | 7 | jobs: |
22 | | - get-secret: |
| 8 | + build-and-deploy: |
23 | 9 | runs-on: ubuntu-latest |
24 | | - |
25 | 10 | steps: |
26 | | - - name: Checkout repository |
27 | | - uses: actions/checkout@v4 |
28 | | - |
29 | | - - name: Azure Login |
| 11 | + - name: Azure login |
30 | 12 | uses: azure/login@v2 |
31 | 13 | with: |
32 | 14 | client-id: ${{ secrets.AZURE_CLIENT_ID }} |
33 | 15 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
34 | 16 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
35 | 17 |
|
36 | | - - name: Retrieve secret from Key Vault |
37 | | - id: keyvault |
38 | | - uses: azure/CLI@v2 |
| 18 | + - name: Azure CLI script |
| 19 | + uses: azure/cli@v2 |
39 | 20 | with: |
| 21 | + azcliversion: latest |
40 | 22 | inlineScript: | |
41 | | - SECRET_VALUE=$(az keyvault secret show --name postgres-host --vault-name ${{ secrets.KEYVAULT_NAME }} --query value -o tsv) |
42 | | - echo "::add-mask::$SECRET_VALUE" |
43 | | - echo "SECRET_VALUE=$SECRET_VALUE" >> $GITHUB_ENV |
44 | | - - name: Use retrieved secret |
45 | | - run: echo "The secret is successfully retrieved!" |
46 | | - |
47 | | - - name: Use SECRET_VALUE in deployment |
48 | | - run: | |
49 | | - ./deploy.sh |
50 | | - env: |
51 | | - SECRET_VALUE: ${{ env.SECRET_VALUE }} |
52 | | - build: |
53 | | - runs-on: ubuntu-latest |
54 | | - |
55 | | - steps: |
56 | | - - uses: actions/checkout@v4 |
57 | | - - name: Set up JDK 21 |
58 | | - uses: actions/setup-java@v4 |
59 | | - with: |
60 | | - java-version: "21" |
61 | | - distribution: "temurin" |
62 | | - cache: maven |
63 | | - - name: Build with Maven |
64 | | - run: mvn -B package --file pom.xml |
| 23 | + az account show |
0 commit comments