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

Secretless PR Builds #641

Merged
merged 37 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a0442ab
Remove sas token from determineartifacturl
aholstrup1 Aug 1, 2023
575d980
Do not read secrets on secretless build
aholstrup1 Aug 1, 2023
36e9e92
Do not get secrets when pull_request trigger
aholstrup1 Aug 1, 2023
fafd6fa
Add setting for secretless builds
aholstrup1 Aug 1, 2023
53c91bd
Replace trigger yaml
aholstrup1 Aug 1, 2023
afe03b2
Refactor
aholstrup1 Aug 1, 2023
78a25b0
Add colon
aholstrup1 Aug 1, 2023
8fcac6d
Update
aholstrup1 Aug 1, 2023
a7539db
Skip pregatecheck for secretless builds
aholstrup1 Aug 1, 2023
8cb6997
Update
aholstrup1 Aug 1, 2023
50fcbe6
Update
aholstrup1 Aug 1, 2023
0ccd868
Change checkforupdates
aholstrup1 Aug 1, 2023
6967032
Update
aholstrup1 Aug 1, 2023
11ad805
Update replaceall
aholstrup1 Aug 2, 2023
53a18f3
Revert changes to determineartifacturl
aholstrup1 Aug 2, 2023
51eac38
Remove whitespace
aholstrup1 Aug 2, 2023
a2d399d
Revert bad change
aholstrup1 Aug 2, 2023
b7018a6
Update settings and releasenotes
aholstrup1 Aug 2, 2023
bd3c64e
Merge branch 'main' into main
aholstrup1 Aug 2, 2023
67d5eb8
Update CheckForUpdates.ps1
aholstrup1 Aug 2, 2023
4d10ce4
Add back repo secrets
aholstrup1 Aug 2, 2023
dbc111c
Merge branch 'main' of https://github.com/aholstrup1/AL-Go
aholstrup1 Aug 2, 2023
97c5053
Defensive check of insidersastoken
aholstrup1 Aug 2, 2023
ae3dc7e
Set insiderSasToken to empty string
aholstrup1 Aug 2, 2023
bc77716
Merge branch 'main' into main
aholstrup1 Aug 2, 2023
02c90c1
Rewrite checkforupdates
aholstrup1 Aug 2, 2023
bdaac0a
Merge branch 'main' of https://github.com/aholstrup1/AL-Go
aholstrup1 Aug 2, 2023
251960b
Update docs
aholstrup1 Aug 2, 2023
fab73a6
Merge branch 'main' into main
aholstrup1 Aug 3, 2023
e5f169e
Merge branch 'main' of https://github.com/microsoft/AL-Go
aholstrup1 Aug 4, 2023
e8856ec
Add default value for build trigger
aholstrup1 Aug 4, 2023
c9bf221
Rename setting
aholstrup1 Aug 4, 2023
662e543
Update Scenarios/settings.md
aholstrup1 Aug 4, 2023
af0f803
Update RELEASENOTES.md
aholstrup1 Aug 4, 2023
4f2b94e
Update setting name
aholstrup1 Aug 4, 2023
3e1e0c7
Update RELEASENOTES.md
aholstrup1 Aug 4, 2023
31a7446
Update casing to PullrequestTrigger
aholstrup1 Aug 7, 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
18 changes: 16 additions & 2 deletions Actions/CheckForUpdates/CheckForUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,30 @@
}
}

# The PullRequestHandler workflow can have a RepoSetting called CICDPullRequestBranches, which will be used to set the branches for the workflow
if ($baseName -eq "PullRequestHandler") {
# The PullRequestHandler workflow can have a RepoSetting called SecretlessPRBuild which will run PR Builds from forks in secretless environments
Fixed Show fixed Hide fixed
$triggerSection = $yaml.Get('on:/')
if (($repoSettings.Keys -contains 'SecretlessPRBuild') -and ($repoSettings.SecretlessPRBuild)) {
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
$prTrigger = "pull_request"
$triggerSection.ReplaceAll("pull_request_target:", "$($prTrigger):")
} else {
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
$prTrigger = "pull_request_target"
$triggerSection.ReplaceAll("pull_request:", "$($prTrigger):")
}
Fixed Show fixed Hide fixed
$yaml.Replace('on:/', $triggerSection.Content)

# The PullRequestHandler workflow can have a RepoSetting called CICDPullRequestBranches, which will be used to set the branches for the workflow
if ($repoSettings.Keys -contains 'CICDPullRequestBranches') {
$CICDPullRequestBranches = $repoSettings.CICDPullRequestBranches
}
else {
$CICDPullRequestBranches = $defaultCICDPullRequestBranches
}

# update the branches: line with the new branches
$yaml.Replace('on:/pull_request_target:/branches:', "branches: [ '$($cicdPullRequestBranches -join "', '")' ]")
$yaml.Replace("on:/$($prTrigger):/branches:", "branches: [ '$($CICDPullRequestBranches -join "', '")' ]")
}

# Repo Setting runs-on and shell determines which GitHub runner is used for all non-build jobs (build jobs are run using the GitHubRunner/GitHubRunnerShell repo settings)
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Now, you can set the checkbox called Use GhTokenWorkflow to allowing you to use

### New Settings
- `keyVaultCodesignCertificateName`: With this setting you can delegate the codesigning to an Azure Key Vault. This can be useful if your certificate has to be stored in a Hardware Security Module
- `SecretlessPRBuild`: With this setting you can ensure that PR Builds triggered by forked repositories don't have access to secrets

### New Actions
- `DownloadProjectDependencies`: Downloads the dependency apps for a given project and build mode.
Expand Down
1 change: 1 addition & 0 deletions Scenarios/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The repository settings are only read from the repository settings file (.github
| <a id="CICDSchedule"></a>CICDSchedule | CRON schedule for when CI/CD workflow should run. Default is no scheduled run, only manually triggered or triggered by Push or Pull Request. Build your CRON string here: [https://crontab.guru](https://crontab.guru) |
| <a id="UpdateGitHubGoSystemFilesSchedule"></a>UpdateGitHubGoSystemFilesSchedule | CRON schedule for when Update AL-Go System Files should run. When Update AL-Go System Files runs on a schedule, it uses direct COMMIT instead of creating a PR. Default is no scheduled run, only manual trigger. Build your CRON string here: [https://crontab.guru](https://crontab.guru) |
| <a id="buildModes"></a>buildModes | A list of build modes to use when building the AL-Go projects. Every AL-Go projects will be built using each built mode. Available build modes are:<br /> **Default**: Apps are compiled as they are in the source code.<br />**Clean**: _PreprocessorSymbols_ are enabled when compiling the apps. The values for the symbols correspond to the `cleanModePreprocessorSymbols` setting of the AL-Go project.<br />**Translated**: `TranslationFile` compiler feature is enabled when compiling the apps. |
| <a id="SecretlessPRBuild"></a>SecretlessPRBuild | Set to true if PR Builds should be triggered by the [pull_request](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request) event. When set to true, workflows triggered from forked repositories will not be able to access secrets with the exception of GITHUB_TOKEN |
aholstrup1 marked this conversation as resolved.
Show resolved Hide resolved

## Advanced settings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:

jobs:
PregateCheck:
if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name
if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request')
runs-on: [ windows-latest ]
steps:
- uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
project: ${{ inputs.project }}

- name: Read secrets
if: github.event_name != 'pull_request'
uses: microsoft/AL-Go-Actions/ReadSecrets@main
env:
secrets: ${{ toJson(secrets) }}
Expand All @@ -102,7 +103,6 @@ jobs:
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
project: ${{ inputs.project }}
settingsJson: ${{ env.Settings }}
secretsJson: ${{ env.RepoSecrets }}
aholstrup1 marked this conversation as resolved.
Show resolved Hide resolved

- name: Cache Business Central Artifacts
if: env.useCompilerFolder == 'True' && inputs.useArtifactCache && steps.determineArtifactUrl.outputs.ArtifactCacheKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:

jobs:
PregateCheck:
if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name
if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request')
runs-on: [ windows-latest ]
steps:
- uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
project: ${{ inputs.project }}

- name: Read secrets
if: github.event_name != 'pull_request'
uses: microsoft/AL-Go-Actions/ReadSecrets@main
env:
secrets: ${{ toJson(secrets) }}
Expand All @@ -102,7 +103,6 @@ jobs:
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
project: ${{ inputs.project }}
settingsJson: ${{ env.Settings }}
secretsJson: ${{ env.RepoSecrets }}

- name: Cache Business Central Artifacts
if: env.useCompilerFolder == 'True' && inputs.useArtifactCache && steps.determineArtifactUrl.outputs.ArtifactCacheKey
Expand Down
Loading