|
1 |
| -# github-action-by-permission |
| 1 | +# RBAC in Github Action |
| 2 | + |
| 3 | +## Why? |
| 4 | +RBAC (Role-Based Access Control) in GitHub Actions provides a mechanism to control who can trigger specific workflows. By using a `permissions.yml` file, you can define the GitHub usernames that are authorized to manually trigger particular pipelines. This setup ensures that only users with explicit permission can execute these workflows, offering enhanced security and strict access control within your CI/CD processes. This approach is ideal for organizations that require granular control over workflow initiation, limiting access to those who are authorized to perform critical actions. |
| 5 | + |
| 6 | +## Status |
| 7 | +Development of this action is still ongoing, with plans to introduce more features in the future, offering even greater flexibility and control over workflow permissions. |
| 8 | + |
| 9 | + |
| 10 | +## Usage |
| 11 | +The `github-action-by-permission` action is designed to enforce Role-Based Access Control (RBAC) for manually triggered (`workflow_dispatch`) GitHub workflows. Here's a simple example of how to use this action to control who can trigger a specific workflow: |
| 12 | + |
| 13 | +```yml |
| 14 | +name: Test Action Trigger Permissions |
| 15 | + |
| 16 | +on: |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + example-job: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Check Permissions |
| 27 | + uses: mokhlesurr031/github-action-by-permission@v1.0 |
| 28 | + with: |
| 29 | + permissions-file: 'user-permissions.yml' //specify your yml file with correct path here |
| 30 | + |
| 31 | + - name: Echo Something |
| 32 | + run: echo "Hello World!" |
| 33 | +``` |
| 34 | +
|
| 35 | +### Explanation |
| 36 | +**Checkout Code**: The first step checks out the repository code using the standard actions/checkout@v3 action. |
| 37 | +
|
| 38 | +**Check Permissions**: The `github-action-by-permission` action is then used to verify if the user who initiated the workflow has permission to do so. It references a yml file (in this case, named user-permissions.yml) where allowed users are defined. |
| 39 | + |
| 40 | +**Echo Something**: If the permission check passes, the workflow proceeds to execute subsequent steps, such as echoing "Hello World!" in this example. You can specify your workflows as needed. |
| 41 | + |
| 42 | +### Key Points |
| 43 | +**permissions-file**: This input points to the YAML file that contains the list of users authorized to trigger the workflow. Only those listed in this file will be able to execute the pipeline. |
| 44 | + |
| 45 | +`Note`: *In general, this `permissions.yaml` file is kept in the root directory of the project*. |
| 46 | +The structure of this file is as below: |
| 47 | + |
| 48 | +```yml |
| 49 | +allowed_users: |
| 50 | +- user1 |
| 51 | +- user2 |
| 52 | +- user3 |
| 53 | +``` |
| 54 | + |
| 55 | +**Security and Control**: By integrating this action into your workflows, you can ensure that only authorized individuals have the ability to initiate critical processes, adding a layer of security and control to your CI/CD pipelines. |
| 56 | + |
| 57 | + |
| 58 | +This example demonstrates how to set up and use the `github-action-by-permission` action to manage access to your GitHub Actions workflows. |
| 59 | + |
| 60 | + |
| 61 | +## Github Repository |
| 62 | +You can visit this repo for the latest release => [Click Here](https://github.com/mokhlesurr031/github-action-by-permission) |
| 63 | + |
| 64 | +And this repo contains the test of this action => [Click Here](https://github.com/mokhlesurr031/test-github-action-by-permission) |
0 commit comments