🛠️ Refactoring on preparation for SSR App deployment #93
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
# This is a basic workflow to help you get started with Actions | |
name: Functions Deployment | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the 'main' branch | |
push: | |
paths-ignore: | |
- "src/AnimeFeedManager.Web**" | |
- "**/*.md" | |
branches: | |
- main | |
pull_request: | |
paths-ignore: | |
- "src/AnimeFeedManager.Web**" | |
- "**/*.md" | |
types: [opened, synchronize, reopened, closed] | |
branches: | |
- main | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
AZURE_FUNCTIONAPP_PACKAGE_PATH: "./src/AnimeFeedManager.Functions" # set this to the path to your web app project, defaults to the repository root | |
TEST_PROJECT_PATH: "./src/AnimeFeedManager.Features.Tests" | |
DOTNET_VERSION: "8.0.x" # set this to the dotnet version to use | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# Updates Azure Infraestructure | |
build-and-deploy-functions: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout GitHub Action | |
uses: actions/checkout@v4.1.1 | |
with: | |
submodules: true | |
clean: true | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
enable-AzPSSession: true | |
# Deploys infrastructure | |
- name: Deploy Azure Infrastructure | |
uses: Azure/arm-deploy@v1 | |
id: infrastructure | |
with: | |
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }} | |
resourceGroupName: ${{ secrets.AZURE_RG }} | |
template: ./deployment/main.bicep | |
parameters: sendgridKey=${{ secrets.SENDGRID_KEY }} email=${{ secrets.SENDER_EMAIL }} | |
failOnStdErr: false | |
# Builds and Deploys functions | |
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Resolve Project Dependencies Using Dotnet | |
shell: bash | |
run: | | |
pushd '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' | |
dotnet publish --configuration Release --output ./output | |
popd | |
- name: Test Using Dotnet | |
shell: bash | |
run: dotnet test '${{ env.TEST_PROJECT_PATH }}' | |
- name: Run Azure Functions Action | |
uses: Azure/functions-action@v1.5.1 | |
id: fa | |
with: | |
slot-name: "Production" | |
app-name: ${{ steps.infrastructure.outputs.appname }} | |
package: "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output" | |
close_pull_request_job: | |
if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
name: Close Pull Request Job | |
steps: | |
- name: Close Pull Request | |
id: closepullrequest | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_DELIGHTFUL_OCEAN_098A2440F }} | |
action: "close" |