Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-688: Azure authentication with Service Principal Federated Credentials #255

Merged
merged 24 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cc41cd1
Updating the login-to-azure action's parameter list for calling azure…
BenedekFarkas Sep 15, 2023
2dfe05c
Modifying the reusable workflows' call to the login-to-azure action
BenedekFarkas Sep 15, 2023
b9ee52c
Updating permissions and secrets of the reusable workflows calling lo…
BenedekFarkas Sep 15, 2023
8e30a3e
Adding the environment property to the reusable workflows' jobs
BenedekFarkas Sep 15, 2023
9ded176
Using the slot-name and destination-slot-name inputs to define the jo…
BenedekFarkas Sep 15, 2023
3b7d344
Disabling most of the steps in the Azure actions to test the authenti…
BenedekFarkas Sep 18, 2023
1442305
Fixing the secret names passed from reset-azure-environment to login-…
BenedekFarkas Sep 18, 2023
e686459
Adding comment to explain Azure authentication secrets, updating Work…
BenedekFarkas Sep 21, 2023
4f67b05
Merge remote-tracking branch 'origin/dev' into issue/OSOE-688
BenedekFarkas Sep 21, 2023
522ce6f
Adding missing required property to the CHECKOUT_TOKEN secrets
BenedekFarkas Sep 21, 2023
c8ad9a9
Updating other secrets in some of the workflows to have a required pr…
BenedekFarkas Sep 21, 2023
eccd213
Updating some workflow branch references to match this issue as expec…
BenedekFarkas Sep 21, 2023
60c03ea
Update Docs/Workflows.md
BenedekFarkas Sep 27, 2023
d0f3e11
Updating Workflows.md
BenedekFarkas Sep 27, 2023
6ca80f2
Updating comments/docs on Azure authentication secrets
BenedekFarkas Sep 27, 2023
d3e3cab
Adding logout-from-azure
BenedekFarkas Sep 27, 2023
5895f57
Fixing copypasta
BenedekFarkas Sep 27, 2023
d4b06d6
Testing the effectiveness of logout-from-azure on reset-azure-environ…
BenedekFarkas Sep 27, 2023
dfd9528
Apparently the recommended course of action for logging out from Azur…
BenedekFarkas Sep 27, 2023
5992722
Removing logout-from-azure stuff for now
BenedekFarkas Sep 27, 2023
6b916c7
Removing testing step from reset-azure-environment
BenedekFarkas Sep 27, 2023
5c8aa5c
Formatting
Piedone Sep 27, 2023
5a469f2
Revert "Disabling most of the steps in the Azure actions to test the …
BenedekFarkas Sep 28, 2023
5fc31a5
Restoring workflow branch references to dev
BenedekFarkas Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/actions/login-to-azure/action.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ runs:
# v1.4.6
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
creds: ${{ env.SERVICE_PRINCIPAL }}
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: ${{ inputs.enable-az-ps-session }}
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
create-jira-issues-for-community-activities:
name: Create Jira issues for community activities
uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@dev
uses: Lombiq/GitHub-Actions/.github/workflows/create-jira-issues-for-community-activities.yml@issue/OSOE-688
secrets:
JIRA_BASE_URL: ${{ secrets.DEFAULT_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.DEFAULT_JIRA_USER_EMAIL }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ on:
required: true
description: The project key in JIRA, i.e. the prefix of issue keys (the "KEY" part of KEY-123).
DISCUSSION_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub discussions, using the internal markup format of Jira
(not Markdown). See the documentation for details.
ISSUE_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub issues, using the internal markup format of Jira (not
Markdown). See the documentation for details.
PULL_REQUEST_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub pull requests, using the internal markup format of Jira
(not Markdown). See the documentation for details.
Expand Down
34 changes: 29 additions & 5 deletions .github/workflows/deploy-orchard1-to-azure-app-service.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,31 @@ name: Deploy Orchard 1 to Azure App Service
concurrency:
group: AzureDeployApp

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
Piedone marked this conversation as resolved.
Show resolved Hide resolved
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL:

# These secrets are used for Azure authentication through Service Principal Federated Credentials with the
# azure/login (https://github.com/azure/login) action, which is proxied by our login-to-azure action below.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID:
required: true
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID:
required: true
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID:
required: true

AZURE_APP_SERVICE_PUBLISH_PROFILE:
required: true

MAINTENANCE_USER_NAME:
MAINTENANCE_PASSWORD:

Expand Down Expand Up @@ -90,25 +104,30 @@ jobs:
deploy:
runs-on: ${{ inputs.machine-type }}
name: Deploy to Azure App Service
environment: ${{ inputs.slot-name }}
defaults:
run:
shell: pwsh
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
if: false
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

- name: Enable Node corepack
if: false
uses: Lombiq/GitHub-Actions/.github/actions/enable-corepack@dev

# Calling nuget restore separately on the actual solution, because we're passing Orchard.proj to the msbuild
# action instead to be able to call the Precompiled target.
- name: Restore NuGet packages
if: false
run: nuget restore ${{ inputs.build-directory }}\${{ inputs.solution-or-project-path }}

- name: Publish Precompiled App
if: false
uses: Lombiq/GitHub-Actions/.github/actions/msbuild@dev
with:
solution-or-project-path: Orchard.proj
Expand All @@ -120,9 +139,11 @@ jobs:
/p:Solution=${{ inputs.build-directory }}\${{ inputs.solution-or-project-path }}

- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@issue/OSOE-688
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand All @@ -140,6 +161,7 @@ jobs:
run: Start-Sleep -Seconds 30

- name: Deploy to Azure App Service
if: false
uses: azure/webapps-deploy@016bdd3f9b7cec60310bcf9da98f671628795644 # v2.2.4
with:
app-name: ${{ inputs.app-name }}
Expand All @@ -148,7 +170,8 @@ jobs:
package: build\Precompiled

- name: Add Azure Application Insights Release Annotation
if: ${{ inputs.application-insights-resource-id != '' }}
if: false
# if: ${{ inputs.application-insights-resource-id != '' }}
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@dev
with:
release-name: "Deploy #${{ github.run_number }} to ${{ inputs.slot-name }}"
Expand All @@ -169,7 +192,8 @@ jobs:
-SlotName ${{ inputs.slot-name }}

- name: Start AfterDeploy Maintenance on the Destination Slot
if: inputs.maintenance-host-name != ''
if: false
# if: inputs.maintenance-host-name != ''
run: |
$maintenanceParameters = @{
HostName = '${{ inputs.maintenance-host-name }}'
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/deploy-to-azure-app-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@ name: Deploy to Azure App Service
concurrency:
group: AzureDeployApp

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL:

# These secrets are used for Azure authentication through Service Principal Federated Credentials with the
# azure/login (https://github.com/azure/login) action, which is proxied by our login-to-azure action below.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID:
required: true
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID:
required: true
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID:
required: true

AZURE_APP_SERVICE_PUBLISH_PROFILE:
required: true

Expand Down Expand Up @@ -113,34 +126,40 @@ jobs:
deploy:
runs-on: ${{ inputs.machine-type }}
name: Deploy to Azure App Service
environment: ${{ inputs.slot-name }}
defaults:
run:
shell: pwsh
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout
if: false
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
token: ${{ secrets.CHECKOUT_TOKEN }}

- name: Set up .NET
if: false
uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev
with:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Enable Node corepack
if: false
uses: Lombiq/GitHub-Actions/.github/actions/enable-corepack@dev

# If runtime is defined, we need to add "--runtime=" to the string so it will be a valid build/publish option. The
# "build-dotnet" action requires the additional switches to be in separate lines (even the parameters), but we can
# take advantage of the dotnet CLI tolerating the usage of the equal sign.
- name: Set up runtime option
if: false
id: set-up-runtime-option
if: ${{ inputs.runtime != '' }}
# if: ${{ inputs.runtime != '' }}
run: |
"runtime-option=--runtime=${{ inputs.runtime }}" >> $Env:GITHUB_OUTPUT

- name: Build and Static Code Analysis
if: false
uses: Lombiq/GitHub-Actions/.github/actions/build-dotnet@dev
with:
directory: ${{ inputs.build-directory }}
Expand All @@ -159,6 +178,7 @@ jobs:
-p:BuildVersionDisplay_BuildUrl=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: Publish
if: false
run: |
dotnet publish (Get-ChildItem ${{ inputs.web-project-path }}).FullName `
--no-build `
Expand All @@ -170,9 +190,11 @@ jobs:
${{ steps.set-up-runtime-option.outputs.runtime-option }}

- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@issue/OSOE-688
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand All @@ -185,6 +207,7 @@ jobs:
-SlotName ${{ inputs.slot-name }}

- name: Deploy to Azure App Service
if: false
uses: azure/webapps-deploy@016bdd3f9b7cec60310bcf9da98f671628795644 # v2.2.4
with:
app-name: ${{ inputs.app-name }}
Expand All @@ -193,6 +216,7 @@ jobs:
package: ${{ inputs.build-directory }}/Published

- name: Add Azure Application Insights Release Annotation
if: false
uses: Lombiq/GitHub-Actions/.github/actions/add-azure-application-insights-release-annotation@dev
with:
release-name: "Deploy #${{ github.run_number }} to ${{ inputs.slot-name }}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/msbuild-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/post-pull-request-checks-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
secrets:
# We can't access org secrets here so they need to be passed in.
MERGE_TOKEN:
required: false
description: >
An authentication token, like a personal access token (PAT), that provides write access to the repository and
can be used to merge the pull request. This is necessary because when a pull request is merged while being
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
Loading