File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
actions/check-permissions Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : ' Check Permissions'
2
+ description : ' Check if the user triggering the workflow is allowed to proceed.'
3
+ inputs :
4
+ permissions-file :
5
+ description : ' Path to the permissions.yml file'
6
+ required : true
7
+ actor :
8
+ description : ' GitHub actor triggering the workflow'
9
+ required : true
10
+ runs :
11
+ using : ' composite'
12
+ steps :
13
+ - name : Set up Python
14
+ uses : actions/setup-python@v4
15
+
16
+ - name : Install PyYAML
17
+ run : pip install pyyaml
18
+ shell : bash
19
+
20
+ - name : Check Permissions
21
+ run : |
22
+ python -c "
23
+ import yaml
24
+ with open('${{ inputs.permissions-file }}', 'r') as f:
25
+ permissions = yaml.safe_load(f)
26
+ if '${{ inputs.actor }}' not in permissions['allowed_users']:
27
+ print('-----------------ERROR--------------------')
28
+ print('User ${{ inputs.actor }} is not allowed to trigger this workflow.')
29
+ print('------------------------------------------')
30
+ exit(1)
31
+ "
32
+ shell : bash
Original file line number Diff line number Diff line change
1
+ name : Example Workflow
2
+ on :
3
+ workflow_dispatch :
4
+ jobs :
5
+ example-job :
6
+ runs-on : ubuntu-latest
7
+ steps :
8
+ - name : Checkout code
9
+ uses : actions/checkout@v3
10
+
11
+ - name : Check Permissions
12
+ uses : ./.github/actions/check-permissions
13
+ with :
14
+ permissions-file : ' permissions.yml'
15
+ actor : ' ${{ github.actor }}'
16
+
17
+ - name : Echo Something
18
+ run : echo "Hello World!"
Original file line number Diff line number Diff line change
1
+ allowed_users :
2
+ - test-user
You can’t perform that action at this time.
0 commit comments