chore: set workflow permission #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| name: Java CI with Maven | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| get-secret: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Azure Login | |
| uses: azure/login@v1 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Retrieve secret from Key Vault | |
| id: keyvault | |
| uses: azure/CLI@v1 | |
| with: | |
| inlineScript: | | |
| SECRET_VALUE=$(az keyvault secret show --name postgres-host --vault-name ${{ secrets.KEYVAULT_NAME }} --query value -o tsv) | |
| echo "::add-mask::$SECRET_VALUE" | |
| echo "SECRET_VALUE=$SECRET_VALUE" >> $GITHUB_ENV | |
| - name: Use retrieved secret | |
| run: echo "The secret is successfully retrieved!" | |
| - name: Use SECRET_VALUE in deployment | |
| run: | | |
| ./deploy.sh | |
| env: | |
| SECRET_VALUE: ${{ env.SECRET_VALUE }} | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "21" | |
| distribution: "temurin" | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml |