Skip to content

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

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

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

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:
AZURE_FUNCTIONAPP_PACKAGE_PATH: 'src/AzureFunction'
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/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: dotnet restore src/AzureFunction/DEPLOY.BikeApp.Function/DEPLOY.BikeApp.Function.csproj
- name: 'Resolve Project Dependencies Using Dotnet'
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
dotnet build --configuration Release --output ./output
popd
- name: 'Publish Artifact for Azure Functions'
uses: actions/upload-artifact@v4
with:
name: function-artifact
path: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
retention-days: 5
overwrite: true
compression-level: 9
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: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output'
- name: Verificando o download do artefato
run: |
ls
ls -la ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output
- name: 'Run Azure Functions Action'
uses: Azure/[email protected]
id: deploy-function-app
with:
app-name: 'func-apim-bike-app' # -lab
slot-name: 'production'
publish-profile: ${{ secrets.FUNCTION_PUBLISH_PROFILE }}
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output
- name: Log out from Azure
run: |
az logout