Repository navigation
127 lines (117 loc) · 5.87 KB
/
Copy pathpackage-command.yaml
File metadata and controls
127 lines (117 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Package Command
env:
APPINSIGHTS: "${{ vars.APPINSIGHTS }}"
DEFAULTPACKAGEVERSION: "${{ vars.DEFAULTPACKAGEVERSION }}"
BASE_FOLDER_PATH: "${{ vars.BASEFOLDERPATH }}"
BRANCH_NAME: "${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}"
GITHUB_APPS_ID: "${{ secrets.APPLICATION_ID }}"
GITHUB_APPS_KEY: "${{ secrets.APPLICATION_PRIVATE_KEY }}"
on:
repository_dispatch:
types: [package-command, Package-command, PACKAGE-command]
concurrency:
group: "GroupName-PackageCommand-${{ github.event.client_payload.pull_request.number || github.run_id }}"
cancel-in-progress: true
jobs:
validate-and-create-package:
if: ${{ !github.event.pull_request.head.repo.fork && !contains(github.event.client_payload.pull_request.head.ref , 'dependabot/') && !contains(github.event.client_payload.pullRequestBranchName , 'dependabot/') }}
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@46e4a501e119d39574a54e53a06c9a705efc55c9
with:
app-id: ${{ env.GITHUB_APPS_ID }}
private-key: ${{ env.GITHUB_APPS_KEY }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
env:
GeneratedToken: ${{ steps.generate_token.outputs.token }}
with:
ref: "${{ env.BRANCH_NAME }}"
fetch-depth: 2
token: ${{ env.GeneratedToken}}
- id: checkAutomatedPR
name: check-Automated-PR
if: ${{ success() }}
env:
BranchName: ${{ github.event.pull_request.head.ref || github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
shell: pwsh
run: |
$pullRequestBranchName = "$env:BranchName"
Write-Host "Pull Request Branch Name is $pullRequestBranchName"
$isAutomatedPR = $false
if ($pullRequestBranchName -like '*automated-pr')
{
Write-Host "Skipping packaging as it is an automated pr!"
$isAutomatedPR = $true
}
Write-Output "isAutomatedPR=$isAutomatedPR" >> $env:GITHUB_OUTPUT
Write-Host "Is this Pull Request autogenerated $isAutomatedPR"
- id: validateAndCreatePackage
name: validate-create-package
if: ${{ success() && steps.checkAutomatedPR.outputs.isAutomatedPR == 'False' }}
env:
RUNID: "${{ github.run_id }}"
PULL_REQUEST_NUMBER: "${{ github.event.client_payload.pull_request.number || github.event.client_payload.pullRequestNumber }}"
shell: pwsh
run: |
$runId = "${{ env.RUNID }}"
$instrumentationKey = "${{ env.APPINSIGHTS }}"
$pullRequestNumber = "${{ env.PULL_REQUEST_NUMBER }}"
$defaultPackageVersion = "${{ env.DEFAULTPACKAGEVERSION }}"
$baseFolderPath = "${{ env.BASE_FOLDER_PATH }}"
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module powershell-yaml
./.script/package-automation/package-service.ps1 $runId $pullRequestNumber $instrumentationKey $baseFolderPath $defaultPackageVersion $false
- name: Upload Artifacts
id: uploadPackageArtifacts
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.IS_CREATE_PACKAGE && env.PACKAGE_CREATION_PATH != '' && env.BLOBNAME != '') }}
uses: actions/upload-artifact@e0057a5b76f2fdad976135e8dd7b691e632b9056
env:
BLOBNAME: "${{ steps.validateAndCreatePackage.outputs.blobName }}"
PACKAGE_CREATION_PATH: "${{ steps.validateAndCreatePackage.outputs.packageCreationPath }}"
DATA_FOLDER_PATH: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
DATA_INPUT_FILE_NAME: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
SOLUTION_NAME: "${{ steps.validateAndCreatePackage.outputs.solutionName }}"
SOLUTION_SUPPORTED_BY: "${{ steps.validateAndCreatePackage.outputs.solutionSupportedBy }}"
RUNID: "${{ github.run_id }}"
PULL_REQUEST_NUMBER: "${{ github.event.client_payload.pull_request.number || github.event.client_payload.pullRequestNumber }}"
IS_CREATE_PACKAGE: ${{ steps.validateAndCreatePackage.outputs.isCreatePackage }}
with:
name: "${{ env.BLOBNAME }}"
path: "${{ env.PACKAGE_CREATION_PATH }}"
- name: Upload Data File Artifacts
id: uploadDataFileArtifact
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.DATA_FOLDER_PATH != '' && env.DATA_INPUT_FILE_NAME != '') }}
uses: actions/upload-artifact@e0057a5b76f2fdad976135e8dd7b691e632b9056
env:
DATA_FOLDER_PATH: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
DATA_INPUT_FILE_NAME: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
with:
name: "${{ env.DATA_INPUT_FILE_NAME }}"
path: "${{ env.DATA_FOLDER_PATH }}"
- name: Push changes to Existing PR
if: ${{ success() && steps.uploadDataFileArtifact.outcome == 'success'}}
run: |
git config --global user.email "noreply@github.com"
git config --global user.name "Github Bot"
git add -A
git commit -m '[skip ci] Github Bot Added package to Pull Request!'
git push
- uses: docker/build-push-action@v2
id: publishGithubPackage
name: Run ARM-TTK
if: ${{ success() }}
continue-on-error: true
env:
SolutionName: "${{ steps.validateAndCreatePackage.outputs.solutionName }}"
mainTemplateChanged: "True"
createUiChanged: "True"
with:
context: .
file: ./.github/actions/Dockerfile
push: false
build-args: |
SolutionName
mainTemplateChanged
createUiChanged