forked from Azure/Azure-Sentinel
-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (34 loc) · 1.24 KB
/
allowedWorkflowRun.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
name: Allowed To Run Workflow
on:
workflow_call:
outputs:
isWorkflowRunAllowed:
description: "Is Allowed to run this workflow!"
value: ${{ jobs.allowedWorkflowRunUsers.outputs.isWorkflowRunAllowed }}
env:
ALLOWED_USERS: "${{ vars.ALLOWEDUSERS }}"
jobs:
allowedWorkflowRunUsers:
if: ${{ !github.event.pull_request.head.repo.fork }}
name: Is Workflow Run Allowed To Current User
runs-on: ubuntu-latest
outputs:
isWorkflowRunAllowed: ${{ steps.getWorkflowRunAllowedStatus.outputs.isWorkflowRunAllowed }}
steps:
- name: Is Current User Allowed
shell: pwsh
id: getWorkflowRunAllowedStatus
run: |
$allowedUsers = "${{ env.ALLOWED_USERS }}"
$currentUser = "${{ github.actor }}"
$isAllowedUser = $allowedUsers.Contains($currentUser)
Write-Host "currentUser $currentUser , isAllowedUser $isAllowedUser"
if ($isAllowedUser)
{
Write-Host "User is allowed to perform execution of workflow!"
}
else
{
Write-Host "User is Not allowed to perform execution of workflow!"
}
Write-Output "isWorkflowRunAllowed=$isAllowedUser" >> $env:GITHUB_OUTPUT