Updated code to fix the bug in CrowdStrike Replicator V2 #1507
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 WORKFLOW WILL GET TRIGGERED WHEN PR IS MERGED IN MASTER | |
name: Package Command On Merge Of PR | |
env: | |
APPINSIGHTS: "${{ vars.APPINSIGHTS }}" | |
DEFAULTPACKAGEVERSION: "${{ vars.DEFAULTPACKAGEVERSION }}" | |
BLOB_CONN_STRING: "${{ secrets.BLOB_CONN_STRING }}" | |
BASE_FOLDER_PATH: "${{ vars.BASEFOLDERPATH }}" | |
BRANCH_NAME: "${{ github.event.pull_request.head.ref }}" | |
GITHUB_APPS_ID: "${{ secrets.APPLICATION_ID }}" | |
GITHUB_APPS_KEY: "${{ secrets.APPLICATION_PRIVATE_KEY }}" | |
on: | |
pull_request: | |
branches: | |
- master | |
paths: | |
- Solutions/** | |
types: | |
- closed | |
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: | |
- 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: | |
fetch-depth: 0 | |
token: ${{ env.GeneratedToken}} | |
- id: checkAutomatedPR | |
name: check-Automated-PR | |
env: | |
BranchName: ${{ github.event.pull_request.head.ref }} | |
shell: pwsh | |
run: | | |
$PRBranchName = "$env:BranchName" | |
Write-Host "Branch Name is $PRBranchName" | |
$isAutomatedPR = $false | |
if ($PRBranchName -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.pull_request.number }}" | |
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 $true | |
- 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.pull_request.number }}" | |
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: createNewPR | |
id: createNewPR | |
if: ${{ success() && steps.uploadDataFileArtifact.outcome == 'success' }} | |
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5 | |
env: | |
SOLUTION_NAME: "${{ steps.validateAndCreatePackage.outputs.solutionName }}" | |
RUNID: "${{ github.run_id }}" | |
PULL_REQUEST_NUMBER: "${{ github.event.pull_request.number }}" | |
ASSIGNEES: "${{ github.actor }}" | |
with: | |
committer: GitHub <noreply@github.com> | |
assignees: "${{ env.ASSIGNEES || github.event.pull_request.head.repo.owner.login }}" | |
signoff: false | |
branch: "${{ env.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 Pull request #${{ env.PULL_REQUEST_NUMBER }}. | |
labels: | | |
auto-package | |
Solution |