Created
November 4, 2020 07:07
-
-
Save justinyoo/d806e47efde7749c6154b19f081f86d2 to your computer and use it in GitHub Desktop.
Deploying Azure Functions via GitHub Actions without Publish Profile
This file contains hidden or 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
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| ... | |
| - name: 'Run Azure Functions Action' | |
| uses: Azure/functions-action@v1 | |
| with: | |
| app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} | |
| package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' | |
| publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} |
This file contains hidden or 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
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Login via Az Module | |
| uses: azure/login@v1 | |
| with: | |
| creds: ${{secrets.AZURE_CREDENTIALS}} | |
| enable-AzPSSession: true |
This file contains hidden or 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
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| ... | |
| - name: Get publish Profile | |
| id: fncapp | |
| shell: pwsh | |
| run: | | |
| $profile = Get-AzWebAppPublishingProfile ` | |
| -ResourceGroupName ${{ secrets.RESOURCE_GROUP_NAME }} ` | |
| -Name ${{ secrets.FUNCTION_APP_NAME }} | |
| $profile = $profile.Replace("`r", "").Replace("`n", "") | |
| Write-Output "::set-output name=profile::$profile" |
This file contains hidden or 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
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| ... | |
| - name: Get publish Profile | |
| id: fncapp | |
| ... | |
| - name: Show publish profile | |
| shell: pwsh | |
| run: | | |
| echo ${{ steps.fncapp.outputs.profile }} |
This file contains hidden or 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
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| ... | |
| - name: Reset publish Profile | |
| shell: pwsh | |
| run: | | |
| $profile = Reset-AzWebAppPublishingProfile ` | |
| -ResourceGroupName ${{ secrets.RESOURCE_GROUP_NAME }} ` | |
| -Name ${{ secrets.FUNCTION_APP_NAME }} | |
| $profile = "" |
This file contains hidden or 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: Build, Test & Deploy | |
| on: push | |
| jobs: | |
| build_test_deploy: | |
| name: 'FunctionApp Build, Test & Deploy' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repo | |
| uses: actions/checkout@v2 | |
| ... | |
| - name: Get FunctionApp publish profile | |
| id: publishprofile | |
| uses: aliencube/publish-profile-actions@v1 | |
| env: | |
| AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS_DEV }} | |
| with: | |
| resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }} | |
| appName: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }} | |
| - name: Deploy FunctionApp | |
| uses: Azure/functions-action@v1 | |
| with: | |
| app-name: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }} | |
| package: published | |
| publish-profile: ${{ steps.publishprofile.outputs.profile }} | |
| - name: Reset FunctionApp publish profile | |
| uses: aliencube/publish-profile-actions@v1 | |
| env: | |
| AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS_DEV }} | |
| with: | |
| resourceGroupName: ${{ secrets.RESOURCE_GROUP_NAME_DEV }} | |
| appName: ${{ secrets.RESOURCE_FUNCTIONAPP_NAME_DEV }} | |
| reset: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment