forked from Azure/Azure-Sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (108 loc) · 5.27 KB
/
package-on-fork.yaml
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
# THIS WORKFLOW WILL GET TRIGGERED WHEN PR IS MERGED IN MASTER
name: Package On Fork PR Merge
env:
APPINSIGHTS: "${{ vars.APPINSIGHTS }}"
DEFAULTPACKAGEVERSION: "${{ vars.DEFAULTPACKAGEVERSION }}"
BLOB_CONN_STRING: "${{ secrets.BLOB_CONN_STRING }}"
BRANCH_NAME: "${{ github.event.pull_request.head.ref }}"
on:
pull_request_target:
branches:
- master
paths:
- Solutions/**
types:
- closed
permissions:
contents: write
pull-requests: write
packages: write
jobs:
if_merged:
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.merged && github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
fetch-depth: 0
- id: checkAutomatedPR
name: check-Automated-PR
env:
BranchName: ${{ github.event.pull_request.head.ref }}
shell: pwsh
run: |
$forkPRBranchName = "$env:BranchName"
Write-Host "Fork Branch Name is $forkPRBranchName"
$isAutomatedPR = $false
if ($forkPRBranchName -like '*automated-pr')
{
Write-Host "Skipping packaging as it is an automated fork pr!"
$isAutomatedPR = $true
}
Write-Output "isAutomatedPR=$isAutomatedPR" >> $env:GITHUB_OUTPUT
Write-Host "Is this Pull Request autogenerated $isAutomatedPR"
- id: validateAndCreatePackage
name: validate-and-create-package
shell: pwsh
if: ${{ success() && steps.checkAutomatedPR.outputs.isAutomatedPR == 'False' }}
env:
RUNID: "${{ github.run_id }}"
PULL_REQUEST_NUMBER: "${{ github.event.pull_request.number }}"
run: |
$runId = "${{ env.RUNID }}"
$instrumentationKey = "${{ vars.APPINSIGHTS }}"
$pullRequestNumber = "${{ env.PULL_REQUEST_NUMBER }}"
$defaultPackageVersion = "${{ env.DEFAULTPACKAGEVERSION }}"
$baseFolderPath = "/home/runner/work/Sentinel/Azure-Sentinel/"
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module powershell-yaml
./.script/package-automation/package-on-fork-pr.ps1 $runId $pullRequestNumber $instrumentationKey $baseFolderPath $defaultPackageVersion
- name: Upload Artifacts
id: uploadPackageArtifacts
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.pull_request.number }}"
IS_CREATE_PACKAGE: ${{ steps.validateAndCreatePackage.outputs.isCreatePackage }}
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.IS_CREATE_PACKAGE && env.PACKAGE_CREATION_PATH != '' && env.BLOBNAME != '') }}
with:
name: "${{ env.BLOBNAME }}"
path: "${{ env.PACKAGE_CREATION_PATH }}"
- name: Upload Data File Artifacts
id: uploadDataFileArtifact
uses: actions/upload-artifact@e0057a5b76f2fdad976135e8dd7b691e632b9056
env:
DATA_FOLDER_PATH: "${{ steps.validateAndCreatePackage.outputs.dataFolderPath }}"
DATA_INPUT_FILE_NAME: "${{ steps.validateAndCreatePackage.outputs.dataInputFileName }}"
if: ${{ success() && (steps.validateAndCreatePackage.outcome == 'success' && env.DATA_FOLDER_PATH != '' && env.DATA_INPUT_FILE_NAME != '') }}
with:
name: "${{ env.DATA_INPUT_FILE_NAME }}"
path: "${{ env.DATA_FOLDER_PATH }}"
- name: create-new-pr
id: create-new-pr
env:
SOLUTION_NAME: "${{ steps.validateAndCreatePackage.outputs.solutionName }}"
PULL_REQUEST_NUMBER: "${{ github.event.pull_request.number }}"
CURRENT_BRANCH_NAME: "${{ github.event.pull_request.head.ref }}"
ASSIGNEES: "${{ github.actor }}"
if: ${{ success() && (steps.validateAndCreatePackage.outputs.isCreatePackage && steps.validateAndCreatePackage.outputs.packageCreationPath != '' && steps.validateAndCreatePackage.outputs.blobName != '') }}
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5
with:
committer: GitHub <noreply@github.com>
assignees: "${{ env.ASSIGNEES }}"
signoff: false
branch: "${{ env.CURRENT_BRANCH_NAME }}-automated-pr"
base: master
delete-branch: false
title: '[GitHub Bot] 🤖 Package Created For ${{ env.SOLUTION_NAME }} Solution'
body: |
Automation have successfully generated package for solution '${{ env.SOLUTION_NAME }}' based on Fork Pull request #${{ env.PULL_REQUEST_NUMBER }}.
labels: |
auto-package
Solution