-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #497 from DFE-Digital/refactor/194327
refactor/194327 - Azure Function Pipeline Optimisation
- Loading branch information
Showing
5 changed files
with
168 additions
and
99 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Build .NET Azure Function App | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
artifact: | ||
type: string | ||
required: true | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-build-azure-function | ||
cancel-in-progress: true | ||
|
||
env: | ||
DOTNET_VERSION: ${{ vars.DOTNET_VERSION }} | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-22.04 | ||
name: Build .NET Azure Function App & Upload Zip Artifact | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Install Dependencies | ||
shell: bash | ||
run: dotnet restore ./src/Dfe.PlanTech.AzureFunctions/Dfe_PlanTech_AzureFunctions.csproj | ||
|
||
- name: Build Azure Function App | ||
shell: bash | ||
run: dotnet publish ./src/Dfe.PlanTech.AzureFunctions/Dfe_PlanTech_AzureFunctions.csproj --configuration Release --no-restore --output ./build | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact }} | ||
path: ./build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
type: string | ||
required: true | ||
artifact: | ||
type: string | ||
required: true | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-deploy-${{ inputs.environment }}-azure-function | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy-image: | ||
runs-on: ubuntu-22.04 | ||
name: Deploy .NET Azure Function App | ||
environment: ${{ inputs.environment }} | ||
env: | ||
AZURE_FUNCTIONAPP_NAME: "${{ secrets.AZ_ENVIRONMENT }}plantechcontentfulfunction" | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Download Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact }} | ||
path: ./build | ||
|
||
- name: Azure CLI Login | ||
uses: ./.github/actions/azure-login | ||
with: | ||
az_tenant_id: ${{ secrets.AZ_TENANT_ID }} | ||
az_subscription_id: ${{ secrets.AZ_SUBSCRIPTION_ID }} | ||
az_client_id: ${{ secrets.AZ_CLIENT_ID }} | ||
az_client_secret: ${{ secrets.AZ_CLIENT_SECRET }} | ||
|
||
- name: Deploy Azure Function App | ||
uses: Azure/functions-action@v1 | ||
with: | ||
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} | ||
package: ./build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Multi-Stage Build & Deploy (Azure Function) | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main", "development"] | ||
paths: | ||
- "src/Dfe.PlanTech.AzureFunctions/**" | ||
- ".github/workflows/matrix-deploy-azure-function.yml" | ||
- ".github/workflows/build-azure-function.yml" | ||
- ".github/workflows/deploy-azure-function.yml" | ||
|
||
jobs: | ||
set-env: | ||
runs-on: ubuntu-22.04 | ||
name: Set Environment (Matrix Deploy Azure Function) | ||
outputs: | ||
branch: ${{ steps.var.outputs.branch }} | ||
artifact: ${{ steps.var.outputs.artifact }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
- id: var | ||
run: | | ||
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}} | ||
ARTIFACT=Dfe-PlanTech-AzureFunction | ||
echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT | ||
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT | ||
build-azure-function: | ||
needs: set-env | ||
name: Build Azure Function | ||
uses: ./.github/workflows/build-azure-function.yml | ||
with: | ||
artifact: ${{ needs.set-env.outputs.artifact }} | ||
|
||
deploy-azure-function-for-dev-test: | ||
needs: [set-env, build-azure-function] | ||
name: Deploy Azure Function | ||
strategy: | ||
fail-fast: true | ||
max-parallel: 2 | ||
matrix: | ||
target: [Dev, Tst] | ||
uses: ./.github/workflows/deploy-azure-function.yml | ||
with: | ||
environment: ${{ matrix.target }} | ||
artifact: ${{ needs.set-env.outputs.artifact }} | ||
secrets: inherit | ||
|
||
deploy-azure-function-for-staging: | ||
needs: [set-env, build-azure-function, deploy-azure-function-for-dev-test] | ||
name: Deploy Azure Function (Staging) | ||
if: ${{ needs.set-env.outputs.branch == 'main' }} | ||
uses: ./.github/workflows/deploy-azure-function.yml | ||
with: | ||
environment: Staging | ||
artifact: ${{ needs.set-env.outputs.artifact }} | ||
secrets: inherit | ||
|
||
deploy-azure-function-for-production: | ||
needs: | ||
[ | ||
set-env, | ||
build-azure-function, | ||
deploy-azure-function-for-dev-test, | ||
deploy-azure-function-for-staging, | ||
] | ||
name: Deploy Azure Function (Production) | ||
if: ${{ needs.set-env.outputs.branch == 'main' }} | ||
uses: ./.github/workflows/deploy-azure-function.yml | ||
with: | ||
environment: Production | ||
artifact: ${{ needs.set-env.outputs.artifact }} | ||
secrets: inherit |
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