felipementel is testing out Azure Function GitHub Actions π #105
This file contains 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
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 }}/output --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 }}/output | |
- name: 'Publish Artifact for Azure Functions' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: function-artifact.zip | |
path: ${{ env.app_path }}/output/ | |
retention-days: 5 | |
overwrite: true | |
compression-level: 9 | |
if-no-files-found: error | |
# - name: 'Build' | |
# shell: bash | |
# run: | | |
# pushd ${{ env.app_path }} | |
# dotnet build --configuration Release --output ./output | |
# popd | |
## | |
# - name: Zip files | |
# run: | | |
# cd ${{ env.app_path }}/output | |
# zip -r ${{ env.app_name }}.zip . | |
# - name: 'Publish Artifact for Azure Functions' | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: function-artifact | |
# path: ${{ env.app_path }}/output | |
# 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: Verificando o download do artefato | |
# run: | | |
# ls | |
# ls -la ./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 |