Solution Repackaged for CTM360 and ESI #1109
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 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 }}" | |
BASE_FOLDER_PATH: "${{ vars.BASEFOLDERPATH }}" | |
GITHUB_APPS_ID: "${{ secrets.APPLICATION_ID }}" | |
GITHUB_APPS_KEY: "${{ secrets.APPLICATION_PRIVATE_KEY }}" | |
on: | |
pull_request_target: | |
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: | | |
$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 = "${{ env.BASE_FOLDER_PATH }}" | |
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 <[email protected]> | |
assignees: "${{ env.ASSIGNEES }}" | |
signoff: false | |
branch: "${{ env.CURRENT_BRANCH_NAME }}-fork-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-fork-package | |
Solution |