Skip to content

Build and deploy to Azure Function App - az204-weather-alert #9

Build and deploy to Azure Function App - az204-weather-alert

Build and deploy to Azure Function App - az204-weather-alert #9

name: Build and deploy to Azure Function App - az204-weather-alert
on:
push:
branches:
- main
paths:
- './weather-alert/**'
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_NAME: az204-weather-alert
PACKAGE_DIRECTORY: 'weather-alert'
JAVA_VERSION: '17'
Build_APP_NAME: 'weather-alert-1742571987789'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Setup Java Sdk ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.13"
- name: Execute Gradle Azure Functions package
run: gradle azureFunctionsPackage
working-directory: ${{ env.PACKAGE_DIRECTORY }}
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v4
with:
build-root-directory: ${{ env.PACKAGE_DIRECTORY }}
gradle-version: "8.13"
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_FUNCTION_CLIENTID }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_F0A2C46FD2B74B6EBF701F4F68664556 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_6A39DE00D4CD4142A2B79B40F2FB0C5A }}
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: '${{ env.PACKAGE_DIRECTORY }}/build/azure-functions/${{ env.Build_APP_NAME }}'