GeezerVison is showing github.com — Add or update the Azure App Service build and deployment workflow config · StephenShenk1/samplejavaapp@f192f1b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy |
| 2 | +# More GitHub Actions for Azure: https://github.com/Azure/actions |
| 3 | + |
| 4 | +name: Build and deploy JAR app to Azure Web App - annawebapp |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Java version |
| 20 | + uses: actions/setup-java@v1 |
| 21 | + with: |
| 22 | + java-version: 'java21' |
| 23 | + |
| 24 | + - name: Build with Maven |
| 25 | + run: mvn clean install |
| 26 | + |
| 27 | + - name: Upload artifact for deployment job |
| 28 | + uses: actions/upload-artifact@v3 |
| 29 | + with: |
| 30 | + name: java-app |
| 31 | + path: '${{ github.workspace }}/target/*.jar' |
| 32 | + |
| 33 | + deploy: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + needs: build |
| 36 | + environment: |
| 37 | + name: 'Production' |
| 38 | + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} |
| 39 | + permissions: |
| 40 | + id-token: write #This is required for requesting the JWT |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Download artifact from build job |
| 44 | + uses: actions/download-artifact@v3 |
| 45 | + with: |
| 46 | + name: java-app |
| 47 | + |
| 48 | + - name: Login to Azure |
| 49 | + uses: azure/login@v1 |
| 50 | + with: |
| 51 | + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_97B9C36D79BC48FAA3580CB1125422E5 }} |
| 52 | + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_87BEF4C938F04B0DB5514637229240AE }} |
| 53 | + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_D46D5ECDA3284069A591B2412F9CF7FB }} |
| 54 | + |
| 55 | + - name: Deploy to Azure Web App |
| 56 | + id: deploy-to-webapp |
| 57 | + uses: azure/webapps-deploy@v2 |
| 58 | + with: |
| 59 | + app-name: 'annawebapp' |
| 60 | + slot-name: 'Production' |
| 61 | + package: '*.jar' |
| 62 | + |