GitHub Action for checking user's permission to access repository.
It takes a required permission and checks if the user can acess the repository with at least the requested level of permissions. Its output can be used e.g. in conditions to contol the execution of subsequent steps of a job.
The minimal required permission.
Possible values: "read"
, "write"
, "admin"
Default: "write"
Possible values:
"1"
if user has required permission, which evaluates totrue
in a GitHub Actions condition.""
otherwise, which evaluates tofalse
.
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Action Sample Workflow
# Run workflow when a new pull request is opened
on: [pull_request]
jobs:
check_user_permission:
runs-on: ubuntu-latest
name: A job to check user's permission level
steps:
# Check for write permission
- name: Check user permission
id: check
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use the output from the `check` step
- name: Run only if user has sufficient permissions
if: steps.check.outputs.has-permission
run: echo "Congratulations! Your permissions to access the repository are sufficient."
- name: Run only if user has NOT sufficient permissions
if: "! steps.check.outputs.has-permission"
run: echo "Sorry! Your permissions are insufficient."
The production-related Node.js modules must be added to this repository to allow the action to run. Modules that are only used for development should not be included in order to reduce the number of files.
Run the following commands to update modules correctly:
echo "Removing all Node.js modules..."
rm -rf package-lock.json node_modules
echo "Installing production-related modules..."
npm install --production
echo "Committing changes..."
git add -f package-lock.json node_modules
git commit -m "chore: Update Node.js modules"
echo "Installing all other modules again..."
npm install