From 4e8ecce4230ed493a1ae1baa34ef4947123f3865 Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 10:19:18 +0000 Subject: [PATCH 1/7] Create function-app-deploy.yml Create a new action to deploy the function app to dev --- .github/workflows/function-app-deploy.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/function-app-deploy.yml diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml new file mode 100644 index 0000000..a91954f --- /dev/null +++ b/.github/workflows/function-app-deploy.yml @@ -0,0 +1,18 @@ +name: Function App Deploy + +on: + release: + types: [published] + +jobs: + build: + name: 'Function App Deploy' + runs-on: ubuntu-latest + steps: + - name: Sign in to Azure + uses: azure/login@v1 + with: + creds: '{"clientId":"${{ secrets.FAD_CLIENT_ID }}","clientSecret":"${{ secrets.FAD_CLIENT_SECRET }}","subscriptionId":"${{ secrets.FAD_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.FAD_TENANT_ID }}"}' + + - name: Deploy Function App (Dev) + run: az functionapp deployment source config --branch main --manual-integration --name s185d01-search --repo-url https://github.com/DFE-Digital/childrens-social-care-cpd-indexer --resource-group s185d01-childrens-social-care-cpd-rg From 24a2dfaa97b7859901418eaa3afb381d86f75819 Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 11:23:42 +0000 Subject: [PATCH 2/7] Update function-app-deploy.yml Parametrised call to az cli --- .github/workflows/function-app-deploy.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index a91954f..3c405aa 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -3,7 +3,19 @@ name: Function App Deploy on: release: types: [published] - + inputs: + workspace: + description: 'Environment to deploy to' + required: true + default: 'Dev' + type: choice + options: + - Dev + - Test + - Pre-Prod + - Prod + - Load-Test + jobs: build: name: 'Function App Deploy' @@ -14,5 +26,5 @@ jobs: with: creds: '{"clientId":"${{ secrets.FAD_CLIENT_ID }}","clientSecret":"${{ secrets.FAD_CLIENT_SECRET }}","subscriptionId":"${{ secrets.FAD_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.FAD_TENANT_ID }}"}' - - name: Deploy Function App (Dev) - run: az functionapp deployment source config --branch main --manual-integration --name s185d01-search --repo-url https://github.com/DFE-Digital/childrens-social-care-cpd-indexer --resource-group s185d01-childrens-social-care-cpd-rg + - name: Deploy Function App + run: az functionapp deployment source config --branch main --manual-integration --name ${{ vars.FAD_FUNCTION_APP_NAME }} --repo-url ${{ github.event.repository.name }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} From e16076842b1073304c86725fa6b277cf294d01c7 Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 11:59:47 +0000 Subject: [PATCH 3/7] Switch to manual and add tag to deploy --- .github/workflows/function-app-deploy.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index 3c405aa..e3261ee 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -1,9 +1,12 @@ name: Function App Deploy on: - release: - types: [published] + workflow_dispatch: inputs: + tag: + description: 'App Tag to deploy' + required: true + default: 'v1.0.0' workspace: description: 'Environment to deploy to' required: true From 146af22615f4d8c08c9bef7e7a2240a46681f56d Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 12:03:13 +0000 Subject: [PATCH 4/7] Select environment to use --- .github/workflows/function-app-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index e3261ee..863bb2d 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -23,6 +23,7 @@ jobs: build: name: 'Function App Deploy' runs-on: ubuntu-latest + environment: ${{ inputs.workspace }} steps: - name: Sign in to Azure uses: azure/login@v1 From e89bba28f6a66a781cbdf1e975288c1139716d1f Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 16:14:31 +0000 Subject: [PATCH 5/7] Use wget to fetch asset --- .github/workflows/function-app-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index 863bb2d..7111e6a 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -30,5 +30,8 @@ jobs: with: creds: '{"clientId":"${{ secrets.FAD_CLIENT_ID }}","clientSecret":"${{ secrets.FAD_CLIENT_SECRET }}","subscriptionId":"${{ secrets.FAD_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.FAD_TENANT_ID }}"}' + - name: Fetch release + run: wget https://github.com/${{ github.event.repository.name }}/archive/refs/tags/${{ inputs.tag }}.zip + - name: Deploy Function App - run: az functionapp deployment source config --branch main --manual-integration --name ${{ vars.FAD_FUNCTION_APP_NAME }} --repo-url ${{ github.event.repository.name }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} + run: az functionapp deployment source config-zip --name ${{ vars.FAD_FUNCTION_APP_NAME }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} ${{ inputs.tag }}.zip From a86fa2ebf3e7deb824210ba0c454b6740854e431 Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 17:41:53 +0000 Subject: [PATCH 6/7] Use repository.name and set --src --- .github/workflows/function-app-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index 7111e6a..9aded47 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -31,7 +31,7 @@ jobs: creds: '{"clientId":"${{ secrets.FAD_CLIENT_ID }}","clientSecret":"${{ secrets.FAD_CLIENT_SECRET }}","subscriptionId":"${{ secrets.FAD_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.FAD_TENANT_ID }}"}' - name: Fetch release - run: wget https://github.com/${{ github.event.repository.name }}/archive/refs/tags/${{ inputs.tag }}.zip + run: wget https://github.com/${{ repository.name }}/archive/refs/tags/${{ inputs.tag }}.zip - name: Deploy Function App - run: az functionapp deployment source config-zip --name ${{ vars.FAD_FUNCTION_APP_NAME }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} ${{ inputs.tag }}.zip + run: az functionapp deployment source config-zip --name ${{ vars.FAD_FUNCTION_APP_NAME }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} --src ${{ inputs.tag }}.zip From 5c41b90f592eff46ea00758d569ca1451c9267dc Mon Sep 17 00:00:00 2001 From: Al West Date: Tue, 9 Jan 2024 17:46:11 +0000 Subject: [PATCH 7/7] Update to use github.repository for repo org/name --- .github/workflows/function-app-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/function-app-deploy.yml b/.github/workflows/function-app-deploy.yml index 9aded47..b53d054 100644 --- a/.github/workflows/function-app-deploy.yml +++ b/.github/workflows/function-app-deploy.yml @@ -31,7 +31,7 @@ jobs: creds: '{"clientId":"${{ secrets.FAD_CLIENT_ID }}","clientSecret":"${{ secrets.FAD_CLIENT_SECRET }}","subscriptionId":"${{ secrets.FAD_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.FAD_TENANT_ID }}"}' - name: Fetch release - run: wget https://github.com/${{ repository.name }}/archive/refs/tags/${{ inputs.tag }}.zip + run: wget https://github.com/${{ github.repository }}/archive/refs/tags/${{ inputs.tag }}.zip - name: Deploy Function App run: az functionapp deployment source config-zip --name ${{ vars.FAD_FUNCTION_APP_NAME }} --resource-group ${{ vars.FAD_RESOURCE_GROUP }} --src ${{ inputs.tag }}.zip