forked from microsoft/ALAppExtensions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync workflows and scripts from BCApps
- Loading branch information
1 parent
290b58c
commit ce3865a
Showing
15 changed files
with
475 additions
and
153 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,50 @@ | ||
name: 'Create Build Tag' | ||
|
||
on: | ||
workflow_run: | ||
workflows: [' CI/CD'] | ||
types: ['completed'] | ||
branches: ['main', 'release/*'] | ||
|
||
run-name: Create build tag on branch ${{ github.ref_name }}. | ||
|
||
jobs: | ||
TagSuccessfulBuild: | ||
if: github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'microsoft' | ||
runs-on: windows-latest | ||
steps: | ||
- name: Create version tag | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
// Query all artifacts from the build workflow | ||
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: context.payload.workflow_run.id, | ||
}); | ||
if(!allArtifacts) { | ||
console.log(`Could not fetch artifacts from run ID ${context.payload.workflow_run.id}`) | ||
return; | ||
} | ||
// Determine the build number, based on the apps artifact name | ||
const appsArtifact = allArtifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name.match(/.*-Apps-.*/) | ||
})[0]; | ||
if(!appsArtifact) { | ||
console.log(`Could not find apps artifact from run ID ${context.payload.workflow_run.id}`) | ||
return; | ||
} | ||
// The build number is after -Apps- | ||
const buildNumber = appsArtifact.name.replace(/.*-Apps-/, "") | ||
const tag = `refs/tags/builds/${buildNumber}` | ||
console.log(`Creating tag: ${tag}`) | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: tag, | ||
sha: context.sha | ||
}); | ||
name: 'Create Build Tag' | ||
|
||
on: | ||
workflow_run: | ||
workflows: [' CI/CD'] | ||
types: [completed] | ||
branches: ['main'] | ||
|
||
run-name: "[${{ github.ref_name }}] Create build tag" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
CreateTag: | ||
if: github.event.workflow_run.conclusion == 'success' | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Build Version | ||
id: GetBuildVersion | ||
env: | ||
buildNumber: ${{ github.event.workflow_run.run_number }} | ||
run: | | ||
Import-Module ".\build\scripts\EnlistmentHelperFunctions.psm1" | ||
$majorMinor = Get-ConfigValue -ConfigType "AL-GO" -Key RepoVersion | ||
$buildVersion = "$($majorMinor).$($env:buildNumber)" | ||
Write-Host "Build Version: $buildVersion" | ||
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "BuildVersion=$buildVersion" | ||
- name: Create version tag | ||
uses: actions/github-script@v6 | ||
env: | ||
BuildVersion: ${{ steps.GetBuildVersion.outputs.BuildVersion}} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const {BuildVersion} = process.env | ||
const tag = `refs/tags/builds/${BuildVersion}` | ||
console.log(`Creating tag: ${tag}`) | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: tag, | ||
sha: context.sha | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class GitHubAPI { | ||
static $GitHubAPIHeader = "X-GitHub-Api-Version: 2022-11-28" | ||
static $AcceptJsonHeader = "Accept: application/vnd.github+json" | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using module .\GitHubAPI.class.psm1 | ||
|
||
<# | ||
Class that represents a GitHub issue. | ||
#> | ||
class GitHubIssue { | ||
$IssueId | ||
$Repository | ||
$Issue | ||
|
||
hidden GitHubIssue([int] $IssueId, [string] $Repository) { | ||
$this.IssueId = $IssueId | ||
$this.Repository = $Repository | ||
|
||
$gitHubIssue = gh api "/repos/$Repository/issues/$IssueId" -H ([GitHubAPI]::AcceptJsonHeader) -H ([GitHubAPI]::GitHubAPIHeader) | ConvertFrom-Json | ||
if ($gitHubIssue.message) { | ||
# message property is populated when the issue is not found | ||
Write-Host "::Warning:: Could not get issue $IssueId from repository $Repository. Error: $($gitHubIssue.message)" | ||
$this.Issue = $null | ||
return | ||
} | ||
$this.Issue = $gitHubIssue | ||
} | ||
|
||
<# | ||
Gets the issue from GitHub. | ||
#> | ||
static [GitHubIssue] Get([int] $IssueId, [string] $Repository) { | ||
$gitHubIssue = [GitHubIssue]::new($IssueId, $Repository) | ||
|
||
if (-not $gitHubIssue.Issue) { | ||
return $null | ||
} | ||
|
||
return $gitHubIssue | ||
} | ||
|
||
<# | ||
Returns true if the issue is approved, otherwise returns false. | ||
Issue is considered approved if it has a label named "approved". | ||
#> | ||
[bool] IsApproved() { | ||
if(-not $this.Issue.labels) { | ||
return $false | ||
} | ||
|
||
return $this.Issue.labels.name -contains "approved" | ||
} | ||
|
||
<# | ||
Returns true if the issue is open, otherwise returns false. | ||
#> | ||
[bool] IsOpen() { | ||
if (-not $this.Issue.state) { | ||
return $false | ||
} | ||
|
||
return $this.Issue.state -eq "open" | ||
} | ||
|
||
[bool] IsPullRequest() { | ||
return $this.Issue.PSobject.Properties.name -eq "pull_request" | ||
} | ||
} |
Oops, something went wrong.