Skip to content

Commit d1969e0

Browse files
committed
Merge branch 'master' into v-sabiraj-awsscriptchanges
2 parents 5bd3dcf + 92e8d87 commit d1969e0

File tree

4,731 files changed

+631519
-147260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,731 files changed

+631519
-147260
lines changed

.github/actions/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ FROM mcr.microsoft.com/powershell:latest
44
ARG SolutionName
55

66
ARG mainTemplateChanged
7-
ENV mainTemplateChanged ${mainTemplateChanged}
7+
ENV mainTemplateChanged=${mainTemplateChanged}
88

99
ARG createUiChanged
10-
ENV createUiChanged ${createUiChanged}
10+
ENV createUiChanged=${createUiChanged}
1111

12-
ENV sname ${SolutionName}
13-
ENV sname1 $SolutionName
12+
ENV sname=${SolutionName}
13+
ENV sname1=$SolutionName
1414
RUN echo "mainTemplateChanged ${mainTemplateChanged}"
1515
RUN echo "createUiChanged ${createUiChanged}"
1616

1717
LABEL version="v1.0"
1818

19-
WORKDIR ./Solutions/$SolutionName
19+
WORKDIR /app/Solutions/$SolutionName
2020

2121
COPY ./Solutions/$SolutionName dist
2222
COPY ./.github/actions/entrypoint.ps1 dist
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Arm-ttk Validations
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
paths:
6+
- 'Solutions/**/mainTemplate.json'
7+
- 'Solutions/**/createUiDefinition.json'
8+
9+
permissions:
10+
contents: read
11+
pull-requests: read
412

513
jobs:
614
run-arm-ttk:
@@ -10,30 +18,33 @@ jobs:
1018
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
1119
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
1220
steps:
13-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1422
with:
1523
fetch-depth: 0
1624
- shell: pwsh
1725
id: step1
1826
name: Identify Changes in PR
1927
run: |
20-
Set-PSRepository PSGallery -InstallationPolicy Trusted
21-
Install-Module powershell-yaml
22-
./.script/package-automation/arm-ttk-tests.ps1
28+
try {
29+
Set-PSRepository PSGallery -InstallationPolicy Trusted
30+
Install-Module powershell-yaml -Force
31+
./.script/package-automation/arm-ttk-tests.ps1
32+
}
33+
catch {
34+
Write-Error "Failed to run ARM-TTK tests: $_"
35+
exit 1
36+
}
2337
24-
- uses: docker/build-push-action@4976231911ebf5f32aad765192d35f942aa48cb8
38+
- uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
2539
id: publishGithubPackage
2640
name: Run ARM-TTK
27-
if: ${{ success() && steps.step1.outcome == 'success' && steps.step1.outputs.solutionName != '' && (steps.step1.outputs.mainTemplateChanged == 'true' || steps.step1.outputs.createUiChanged == 'true') }}
28-
env:
29-
SolutionName: ${{ steps.step1.outputs.solutionName }}
30-
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }}
31-
createUiChanged: ${{ steps.step1.outputs.createUiChanged }}
41+
if: ${{ success() && steps.step1.outputs.solutionName != '' && (steps.step1.outputs.mainTemplateChanged == 'true' || steps.step1.outputs.createUiChanged == 'true') }}
3242
with:
3343
context: .
3444
file: ./.github/actions/Dockerfile
3545
push: false
46+
provenance: false
3647
build-args: |
37-
SolutionName
38-
mainTemplateChanged
39-
createUiChanged
48+
SolutionName=${{ steps.step1.outputs.solutionName }}
49+
mainTemplateChanged=${{ steps.step1.outputs.mainTemplateChanged }}
50+
createUiChanged=${{ steps.step1.outputs.createUiChanged }}

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'javascript', 'python', 'ruby' ]
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35+
language: [ 'javascript', 'python', 'ruby', 'actions' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'actions' ]
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

3939
steps:

.github/workflows/package-command.yaml

Lines changed: 112 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,124 +4,155 @@ env:
44
DEFAULTPACKAGEVERSION: "${{ vars.DEFAULTPACKAGEVERSION }}"
55
BASE_FOLDER_PATH: "${{ vars.BASEFOLDERPATH }}"
66
BRANCH_NAME: "${{ github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}"
7-
GITHUB_APPS_ID: "${{ secrets.APPLICATION_ID }}"
8-
GITHUB_APPS_KEY: "${{ secrets.APPLICATION_PRIVATE_KEY }}"
7+
PULL_REQUEST_NUMBER: "${{ github.event.client_payload.pull_request.number || github.event.client_payload.pullRequestNumber }}"
98

109
on:
1110
repository_dispatch:
1211
types: [package-command, Package-command, PACKAGE-command]
1312

1413
concurrency:
15-
group: "GroupName-PackageCommand-${{ github.event.client_payload.pull_request.number || github.run_id }}"
14+
group: "package-command-${{ github.event.client_payload.pull_request.number || github.run_id }}"
1615
cancel-in-progress: true
1716

17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
actions: read
21+
1822
jobs:
1923
validate-and-create-package:
2024
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/') }}
2125
runs-on: ubuntu-latest
26+
outputs:
27+
is-automated-pr: ${{ steps.checkAutomatedPR.outputs.isAutomatedPR }}
28+
package-created: ${{ steps.validateAndCreatePackage.outputs.isCreatePackage }}
2229
steps:
30+
- name: Validate inputs
31+
run: |
32+
if [ -z "${{ env.BRANCH_NAME }}" ]; then
33+
echo "::error::Branch name is required"
34+
exit 1
35+
fi
36+
if [ -z "${{ env.PULL_REQUEST_NUMBER }}" ]; then
37+
echo "::error::Pull request number is required"
38+
exit 1
39+
fi
40+
41+
- name: Checkout repository
42+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
with:
44+
ref: "${{ env.BRANCH_NAME }}"
45+
fetch-depth: 0
46+
persist-credentials: false # Disable automatic token authentication
47+
# Do not use privileged token for untrusted code checkout
48+
2349
- name: Generate a token
2450
id: generate_token
25-
uses: actions/create-github-app-token@46e4a501e119d39574a54e53a06c9a705efc55c9
51+
uses: actions/create-github-app-token@333678481b1f02ee31fa1443aba4f1f7cb5b08b5 # v2.0.0
2652
with:
27-
app-id: ${{ env.GITHUB_APPS_ID }}
28-
private-key: ${{ env.GITHUB_APPS_KEY }}
53+
app-id: ${{ secrets.APPLICATION_ID }}
54+
private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
55+
owner: ${{ github.repository_owner }}
56+
repositories: ${{ github.event.repository.name }}
2957

30-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
58+
- name: Check if PR branch is up to date with master
59+
id: check_up_to_date
60+
shell: bash
3161
env:
32-
GeneratedToken: ${{ steps.generate_token.outputs.token }}
33-
with:
34-
ref: "${{ env.BRANCH_NAME }}"
35-
fetch-depth: 2
36-
token: ${{ env.GeneratedToken}}
62+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
63+
run: |
64+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
65+
git fetch origin master
66+
BASE=$(git merge-base HEAD origin/master)
67+
if [ "$BASE" = "$(git rev-parse HEAD)" ]; then
68+
echo "skip_pipeline=true" >> $GITHUB_ENV
69+
echo "PR branch is up to date with master. Skipping pipeline."
70+
else
71+
echo "skip_pipeline=false" >> $GITHUB_ENV
72+
fi
3773
38-
- id: checkAutomatedPR
39-
name: check-Automated-PR
40-
if: ${{ success() }}
41-
env:
42-
BranchName: ${{ github.event.pull_request.head.ref || github.event.client_payload.pull_request.head.ref || github.event.client_payload.pullRequestBranchName }}
74+
- name: Check for automated PR
75+
id: checkAutomatedPR
76+
if: env.skip_pipeline != 'true'
4377
shell: pwsh
4478
run: |
45-
$pullRequestBranchName = "$env:BranchName"
46-
Write-Host "Pull Request Branch Name is $pullRequestBranchName"
47-
$isAutomatedPR = $false
48-
if ($pullRequestBranchName -like '*automated-pr')
49-
{
79+
$branchName = "${{ env.BRANCH_NAME }}"
80+
Write-Host "Pull Request Branch Name is $branchName"
81+
$isAutomatedPR = $branchName -like '*automated-pr'
82+
if ($isAutomatedPR) {
5083
Write-Host "Skipping packaging as it is an automated pr!"
51-
$isAutomatedPR = $true
5284
}
53-
Write-Output "isAutomatedPR=$isAutomatedPR" >> $env:GITHUB_OUTPUT
54-
Write-Host "Is this Pull Request autogenerated $isAutomatedPR"
85+
"isAutomatedPR=$($isAutomatedPR.ToString().ToLower())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
86+
Write-Host "Is this Pull Request autogenerated: $isAutomatedPR"
5587
56-
- id: validateAndCreatePackage
57-
name: validate-create-package
58-
if: ${{ success() && steps.checkAutomatedPR.outputs.isAutomatedPR == 'False' }}
59-
env:
60-
RUNID: "${{ github.run_id }}"
61-
PULL_REQUEST_NUMBER: "${{ github.event.client_payload.pull_request.number || github.event.client_payload.pullRequestNumber }}"
88+
- name: Validate and create package
89+
id: validateAndCreatePackage
90+
if: steps.checkAutomatedPR.outputs.isAutomatedPR == 'false' && env.skip_pipeline != 'true'
6291
shell: pwsh
6392
run: |
64-
$runId = "${{ env.RUNID }}"
93+
$runId = "${{ github.run_id }}"
6594
$instrumentationKey = "${{ env.APPINSIGHTS }}"
6695
$pullRequestNumber = "${{ env.PULL_REQUEST_NUMBER }}"
6796
$defaultPackageVersion = "${{ env.DEFAULTPACKAGEVERSION }}"
6897
$baseFolderPath = "${{ env.BASE_FOLDER_PATH }}"
69-
Set-PSRepository PSGallery -InstallationPolicy Trusted
70-
Install-Module powershell-yaml
71-
./.script/package-automation/package-service.ps1 $runId $pullRequestNumber $instrumentationKey $baseFolderPath $defaultPackageVersion $false
98+
# Validate required parameters
99+
if ([string]::IsNullOrEmpty($runId)) {
100+
Write-Error "Run ID is required"
101+
exit 1
102+
}
103+
if ([string]::IsNullOrEmpty($pullRequestNumber)) {
104+
Write-Error "Pull Request Number is required"
105+
exit 1
106+
}
107+
try {
108+
Set-PSRepository PSGallery -InstallationPolicy Trusted
109+
Install-Module powershell-yaml -Force
110+
./.script/package-automation/package-service.ps1 $runId $pullRequestNumber $instrumentationKey $baseFolderPath $defaultPackageVersion $false
111+
}
112+
catch {
113+
Write-Error "Package creation failed: $_"
114+
exit 1
115+
}
72116
73-
- name: Upload Artifacts
117+
- name: Upload package artifacts
74118
id: uploadPackageArtifacts
75-
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.IS_CREATE_PACKAGE && env.PACKAGE_CREATION_PATH != '' && env.BLOBNAME != '') }}
76-
uses: actions/upload-artifact@e0057a5b76f2fdad976135e8dd7b691e632b9056
77-
env:
78-
BLOBNAME: "${{ steps.validateAndCreatePackage.outputs.blobName }}"
79-
PACKAGE_CREATION_PATH: "${{ steps.validateAndCreatePackage.outputs.packageCreationPath }}"
80-
DATA_FOLDER_PATH: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
81-
DATA_INPUT_FILE_NAME: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
82-
SOLUTION_NAME: "${{ steps.validateAndCreatePackage.outputs.solutionName }}"
83-
SOLUTION_SUPPORTED_BY: "${{ steps.validateAndCreatePackage.outputs.solutionSupportedBy }}"
84-
RUNID: "${{ github.run_id }}"
85-
PULL_REQUEST_NUMBER: "${{ github.event.client_payload.pull_request.number || github.event.client_payload.pullRequestNumber }}"
86-
IS_CREATE_PACKAGE: ${{ steps.validateAndCreatePackage.outputs.isCreatePackage }}
119+
if: |
120+
steps.validateAndCreatePackage.outcome == 'success' &&
121+
steps.validateAndCreatePackage.outputs.isCreatePackage == 'true' &&
122+
steps.validateAndCreatePackage.outputs.uploadPackagePath != '' &&
123+
steps.validateAndCreatePackage.outputs.blobName != ''
124+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
87125
with:
88-
name: "${{ env.BLOBNAME }}"
89-
path: "${{ env.PACKAGE_CREATION_PATH }}"
126+
name: "${{ steps.validateAndCreatePackage.outputs.blobName }}"
127+
path: |
128+
${{ steps.validateAndCreatePackage.outputs.uploadPackagePath }}
129+
${{ steps.validateAndCreatePackage.outputs.packageCreationPath }}*.json
130+
retention-days: 20 # Override default 90 days for cost optimization
90131

91-
- name: Upload Data File Artifacts
132+
- name: Upload data file artifacts
92133
id: uploadDataFileArtifact
93-
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.DATA_FOLDER_PATH != '' && env.DATA_INPUT_FILE_NAME != '') }}
94-
uses: actions/upload-artifact@e0057a5b76f2fdad976135e8dd7b691e632b9056
95-
env:
96-
DATA_FOLDER_PATH: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
97-
DATA_INPUT_FILE_NAME: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
134+
if: |
135+
steps.validateAndCreatePackage.outcome == 'success' &&
136+
steps.validateAndCreatePackage.outputs.dataFolderPath != '' &&
137+
steps.validateAndCreatePackage.outputs.dataInputFileName != ''
138+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
98139
with:
99-
name: "${{ env.DATA_INPUT_FILE_NAME }}"
100-
path: "${{ env.DATA_FOLDER_PATH }}"
140+
name: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
141+
path: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
142+
retention-days: 20 # Override default 90 days for cost optimization
101143

102-
- name: Push changes to Existing PR
103-
if: ${{ success() && steps.uploadDataFileArtifact.outcome == 'success'}}
144+
- name: Push changes to existing PR
145+
if: steps.uploadDataFileArtifact.outcome == 'success'
146+
env:
147+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
104148
run: |
105149
git config --global user.email "[email protected]"
106-
git config --global user.name "Github Bot"
150+
git config --global user.name "GitHub Actions Bot"
151+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
107152
git add -A
108-
git commit -m '[skip ci] Github Bot Added package to Pull Request!'
109-
git push
110-
111-
- uses: docker/build-push-action@v2
112-
id: publishGithubPackage
113-
name: Run ARM-TTK
114-
if: ${{ success() }}
115-
continue-on-error: true
116-
env:
117-
SolutionName: "${{ steps.validateAndCreatePackage.outputs.solutionName }}"
118-
mainTemplateChanged: "True"
119-
createUiChanged: "True"
120-
with:
121-
context: .
122-
file: ./.github/actions/Dockerfile
123-
push: false
124-
build-args: |
125-
SolutionName
126-
mainTemplateChanged
127-
createUiChanged
153+
if ! git diff --cached --quiet; then
154+
git commit -m '[skip ci] Automated package addition to Pull Request'
155+
git push origin HEAD:${{ env.BRANCH_NAME }}
156+
else
157+
echo "No changes to commit"
158+
fi

0 commit comments

Comments
 (0)