Skip to content

felipementel is testing out Azure Function GitHub Actions πŸš€ #112

felipementel is testing out Azure Function GitHub Actions πŸš€

felipementel is testing out Azure Function GitHub Actions πŸš€ #112

name: Function CI/CD
run-name: ${{ github.actor }} is testing out Azure Function GitHub Actions πŸš€
on:
push:
branches:
- main
- '!feature/**'
paths:
- 'src/AzureFunction/**'
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
branches:
- main
- '!feature/**'
paths:
- 'src/AzureFunction/**'
env:
app_full_path: ./src/AzureFunction/DEPLOY.BikeApp.Function/DEPLOY.BikeApp.Function.csproj
app_path: ./src/AzureFunction/DEPLOY.BikeApp.Function
app_root: ./src/AzureFunction/
app_name: func-apim-bike-api-lab
jobs:
build:
# environment: lab
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0.x']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/[email protected]
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: |
dotnet restore ${{ env.app_full_path }}
- name: Build
run: |
dotnet build ${{ env.app_full_path }} --configuration Release --output ${{ env.app_path }}/output3 --no-incremental
# - name: 'Run Azure Functions Action'
# uses: Azure/[email protected]
# id: deploy-function-app
# with:
# app-name: ${{ env.app_name }}
# slot-name: 'production'
# publish-profile: ${{ secrets.FUNCTION_PUBLISH_PROFILE }}
# package: ${{ env.app_path }}/output3
- name: 'Publish Artifact for Azure Functions'
uses: actions/upload-artifact@v4
with:
name: function-artifact
path: ${{ env.app_path }}/output3
retention-days: 5
overwrite: true
compression-level: 9
if-no-files-found: error
deploy:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Log in to Azure
uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Download Artifact for Azure Functions
uses: actions/download-artifact@v4
with:
name: function-artifact
path: ./output
- name: Unzip
run: |
unzip ./output/function-artifact.zip -d ./output
- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
id: deploy-function-app
with:
app-name: ${{ env.app_name }}
slot-name: 'production'
publish-profile: ${{ secrets.FUNCTION_PUBLISH_PROFILE }}
package: ./output
- name: Log out from Azure
run: |
az logout