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

Run "Update AL-Go System Files" on multiple branches #1037

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
de2ddd1
Run "Update AL-Go System Files" on multiple branches
mazhelez Apr 15, 2024
6daba1a
Run GetBranches on windows-latest by default
mazhelez Apr 15, 2024
06589ab
Convert to JSON array
mazhelez Apr 15, 2024
b0b3020
JSON stuff
mazhelez Apr 15, 2024
fc39d35
Always use array
mazhelez Apr 15, 2024
5abda87
🤦‍♀️
mazhelez Apr 15, 2024
c8399f3
🤦‍♀️
mazhelez Apr 15, 2024
9b29103
🤦‍♀️
mazhelez Apr 15, 2024
25640df
Add name property to GetBranches
mazhelez Apr 15, 2024
e760d59
Convert arrays to JSON
mazhelez Apr 15, 2024
c4ea9e0
Fix typo
mazhelez Apr 15, 2024
f441952
Default to main in AL-Go settings
mazhelez Apr 15, 2024
40eb235
Use invoke-git
mazhelez Apr 15, 2024
57b08f8
Fix README
mazhelez Apr 15, 2024
e60b51e
Minor fixes
mazhelez Apr 15, 2024
b3ed51c
Import GitHub helper
mazhelez Apr 15, 2024
2c29e00
Import GitHub module better
mazhelez Apr 15, 2024
72a40df
Add logs
mazhelez Apr 15, 2024
bc88077
Debugging
mazhelez Apr 15, 2024
7dab72d
Fix issue with types
mazhelez Apr 15, 2024
77e72f8
Fix param name
mazhelez Apr 15, 2024
14be591
Add -returnValue param to invoke-git
mazhelez Apr 15, 2024
1b8dbc8
Use matrix branch for CheckForUpdates
mazhelez Apr 15, 2024
1198bad
Fix outputs
mazhelez Apr 19, 2024
ba160a3
Add parenthesis
mazhelez Apr 19, 2024
1578131
Fix mistake when assigning output
mazhelez Apr 19, 2024
b80bbec
Merge branch 'main' into update-al-go-multiple-branches
mazhelez May 14, 2024
3c3a6e9
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Jun 25, 2024
9c3e8cb
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Jun 25, 2024
eb8ce45
Minor improvements
mazhelez Jun 25, 2024
8bada67
Propagate changes to the App Source template
mazhelez Jun 25, 2024
b5fffcd
Add action tests
mazhelez Jun 25, 2024
e209f53
Do not set default value for updateALGoBranches
mazhelez Jun 25, 2024
3f84587
Add release notes
mazhelez Jun 25, 2024
2ec56a4
Merge branch 'update-al-go-multiple-branches' of https://github.com/m…
mazhelez Jun 25, 2024
a853021
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Aug 7, 2024
3c603e2
Use GitHub variable instead of an AL-Go setting
mazhelez Aug 7, 2024
c30e162
Remove updateALGoBranches setting
mazhelez Aug 7, 2024
a1ca3da
Sync templates files
mazhelez Aug 7, 2024
f53c605
Fix doc and test file name
mazhelez Aug 7, 2024
0ae7c48
Improve release notes
mazhelez Aug 7, 2024
29e3dde
Fix branch name in YAML file
mazhelez Aug 7, 2024
a9874f1
Remove description from YAML to fix tests
mazhelez Aug 7, 2024
a31a479
Uptake action wrapper
mazhelez Aug 7, 2024
1e7f290
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Sep 27, 2024
25bd499
Use settings for when updating AL-Go on a schedule
mazhelez Sep 27, 2024
d68b12f
Fix README
mazhelez Sep 27, 2024
59b8496
Propagate changes to the PTE template
mazhelez Sep 27, 2024
7694e52
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Oct 30, 2024
58e2a70
Fix release notes
mazhelez Oct 30, 2024
1c96a5f
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Nov 11, 2024
69aca8b
Merge branch 'main' of https://github.com/mazhelez/AL-Go into update-…
mazhelez Dec 12, 2024
39e79b6
Fixes
mazhelez Dec 12, 2024
cd920cd
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Dec 12, 2024
2fc7ca5
Remove updateALGoSystemFilesSettings setting. Add scheduleSettings
mazhelez Dec 12, 2024
5db6867
Use ghTokenWorkflow instead of TokenForPush.
mazhelez Dec 12, 2024
748b633
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Dec 13, 2024
8c1fdaa
Add checkbox to update multiple branches
mazhelez Dec 19, 2024
5795eff
Sync workflows
mazhelez Dec 19, 2024
b025bc1
Fix action refs
mazhelez Dec 19, 2024
d5d078b
Minor fixes
mazhelez Dec 30, 2024
85eae0a
Use ubuntu-latest and pwsh
mazhelez Dec 30, 2024
baf2189
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Jan 7, 2025
ecdfd5a
Use activeBranch as base branch when creating a PR
mazhelez Jan 7, 2025
5b7c333
Debug PR creation
mazhelez Jan 8, 2025
488b62b
Propagate the branch to update
mazhelez Jan 8, 2025
075386d
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Jan 28, 2025
3f4ea62
Fix JSON-related issue with arrays
mazhelez Jan 28, 2025
f3fb6da
Propagate changes
mazhelez Jan 28, 2025
5f73ca0
Output ResultJSON in GetGitBranches
mazhelez Jan 28, 2025
6eedf0f
Silent git fetch
mazhelez Jan 28, 2025
4ce5d21
Fix action output name
mazhelez Jan 28, 2025
bb63c6c
Fix variable name
mazhelez Jan 28, 2025
d7987ae
Use windows-latest and powershell
mazhelez Jan 28, 2025
8da9f6d
Fix failing test
mazhelez Jan 29, 2025
e8d3bc4
Merge branch 'main' of https://github.com/microsoft/AL-Go into update…
mazhelez Feb 5, 2025
c70aa36
Rename action + remove extra logic from YAML into PS
mazhelez Feb 5, 2025
c53e1bf
Fix release notes
mazhelez Feb 5, 2025
dd7d595
Fix settings doc
mazhelez Feb 5, 2025
8dabfbd
Fix failing tests
mazhelez Feb 5, 2025
793b017
Add more tests
mazhelez Feb 5, 2025
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
1 change: 1 addition & 0 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ function ReadSettings {
$settings = [ordered]@{
"type" = "PTE"
"unusedALGoSystemFiles" = @()
"updateALGoBranches" = @("main")
"projects" = @()
"powerPlatformSolutionFolder" = ""
"country" = "us"
Expand Down
27 changes: 27 additions & 0 deletions Actions/GetGitBranches/GetGitBranches.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
param(
[Parameter(Mandatory = $false, HelpMessage = "JSON-formatted array of branches to include if they exist. If not specified, all branches are returned. Wildcards are supported.")]
[string] $includeBranchesJson = '[]'
)

$gitHubHelperPath = Join-Path $PSScriptRoot '../Github-Helper.psm1' -Resolve
Import-Module $gitHubHelperPath -DisableNameChecking

invoke-git fetch
$allBranches = @(invoke-git -returnValue for-each-ref --format="%(refname:short)" refs/remotes/origin | ForEach-Object { $_ -replace 'origin/', '' })

$includeBranches = ConvertFrom-Json $includeBranchesJson
if ($includeBranches) {
Write-Host "Filtering branches by: $($includeBranches -join ', ')"
$branches = @()
foreach ($branchFilter in $includeBranches) {
$branches += $allBranches | Where-Object { $_ -like $branchFilter }
}
}
else {
$branches = $allBranches
}

Write-Host "Found git branches: $($branches -join ', ')"

# Add the branches to the output
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "Branches=$(ConvertTo-Json $branches -Depth 99 -Compress)"
23 changes: 23 additions & 0 deletions Actions/GetGitBranches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Get Git Branches
Gets current git branches defined on the remote repository

## INPUT

### ENV variables
none

### Parameters
| Name | Required | Description | Default value |
| :-- | :-: | :-- | :-- |
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| includeBranches | | JSON-formatted array of branches to include if they exist. If not specified, all branches are returned. Wildcards are supported. ||

## OUTPUT

### ENV variables
none

### OUTPUT variables
| Name | Description |
| :-- | :-- |
| Branches | The list of branches on the remote repository |
36 changes: 36 additions & 0 deletions Actions/GetGitBranches/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Get Git Branches
author: Microsoft Corporation
description: Get the list of branches in the repository
inputs:
shell:
description: Shell in which you want to run the action (powershell or pwsh)
required: false
default: powershell
includeBranchesJson:
description: JSON-formatted array of branches to include if they exist. If not specified, all branches are returned. Wildcards are supported.
required: false
default: '[]'
outputs:
Branches:
description: The list of branches in the repository
value: ${{ steps.GetGitBranches.outputs.Branches }}
runs:
using: composite
steps:
- name: run
shell: ${{ inputs.shell }}
id: GetGitBranches
env:
_includeBranchesJson: ${{ inputs.includeBranchesJson }}
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
mazhelez marked this conversation as resolved.
Show resolved Hide resolved
try {
${{ github.action_path }}/GetGitBranches.ps1 -includeBranchesJson $env:_includeBranchesJson
}
catch {
Write-Host "::ERROR::Unexpected error when running action. Error Message: $($_.Exception.Message.Replace("`r",'').Replace("`n",' ')), StackTrace: $($_.ScriptStackTrace.Replace("`r",'').Replace("`n",' <- '))";
exit 1
}
branding:
icon: terminal
color: blue
2 changes: 1 addition & 1 deletion Actions/ReadSettings/ReadSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $settings.Keys | ForEach-Object {
}
$outSettings += @{ "$setting" = $settingValue }
if ($getSettings -contains $setting) {
if ($settingValue -is [System.Collections.Specialized.OrderedDictionary] -or $settingValue -is [hashtable]) {
if ($settingValue -is [System.Collections.Specialized.OrderedDictionary] -or $settingValue -is [hashtable] -or $settingValue -is [array]) {
Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "$setting=$(ConvertTo-Json $settingValue -Depth 99 -Compress)"
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,52 @@ env:
ALGoRepoSettings: ${{ vars.ALGoRepoSettings }}

jobs:
GetBranches:
runs-on: windows-latest
name: Get Supported Branches
outputs:
SupportedBranches: ${{ steps.DetermineBranches.outputs.Result }}
steps:
- name: Checkout
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: actions/checkout@v4

- name: Read settings
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: microsoft/AL-Go-Actions/ReadSettings@main
with:
shell: powershell
get: updateALGoBranches

- name: Get Supported Branches
if: ${{ github.event_name != 'workflow_dispatch' }}
id: GetSupportedBranches
uses: microsoft/AL-Go-Actions/GetGitBranches@main
with:
shell: powershell
includeBranchesJson: ${{ env.updateALGoBranches }}

- name: Determine branches to update
id: DetermineBranches
run: |
if (${{ github.event_name }} -eq 'workflow_dispatch') {
Write-Host "Running Update AL-Go System Files on a manual trigger."
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "Result=['${{ github.ref_name }}']"
}
else {
Write-Host "Running Update AL-Go System Files on a schedule."
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "Result=$(${{ steps.GetSupportedBranches.outputs.Branches }})"
}

UpdateALGoSystemFiles:
needs: [ ]
needs: [ GetBranches ]
runs-on: [ windows-latest ]
name: "[${{ matrix.branch }}] Update AL-Go"
freddydk marked this conversation as resolved.
Show resolved Hide resolved
strategy:
matrix:
branch: ${{ fromJson(needs.GetBranches.outputs.SupportedBranches) }}
fail-fast: false

steps:
- name: Dump Workflow Information
uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@main
Expand All @@ -39,6 +82,8 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Initialize the workflow
id: init
Expand Down Expand Up @@ -99,6 +144,7 @@ jobs:
update: 'Y'
templateUrl: ${{ env.templateUrl }}
directCommit: ${{ env.directCommit }}
updateBranch: ${{ matrix.branch }}

- name: Finalize the workflow
if: always()
Expand Down
Loading