https://github.com/dpvreony/ensure-environment-protected
Github action to ensure an environment exists and has protection rules
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.7%) to scientific vocabulary
Repository
Github action to ensure an environment exists and has protection rules
Basic Info
- Host: GitHub
- Owner: dpvreony
- License: mit
- Default Branch: main
- Size: 25.4 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
Check GitHub Environment Action
This GitHub Action checks if a specified environment exists in the repository and verifies whether protection rules (such as approvals) are configured. It is useful for ensuring environments are properly set up before running further actions, like deploying to production.
Features
- Checks if the specified environment exists in the repository.
- Verifies if the environment has protection rules configured (like required approvals).
- Fails gracefully with detailed error messages when permissions or setup are missing.
Inputs
| Name | Description | Required | Default |
|------------------|-----------------------------------------------------------------------------|----------|---------|
| github_token | The GitHub token used to authenticate API requests. | true | N/A |
| environment_name| The name of the environment to check (e.g., production, staging). | true | N/A |
Outputs
This action does not produce any outputs but will fail the workflow if: - The environment does not exist. - The environment has no protection rules (such as required approvals). - The action lacks necessary permissions to read the environment or its rules.
Example Usage
```yaml name: Check Environment and Deploy
on: push: branches: - main
jobs: check-environment: runs-on: ubuntu-latest permissions: actions: read contents: read deployments: read steps: - name: Check if 'production' environment exists and has protection rules uses: dpvreony/ensure-environment-protected@main with: githubtoken: ${{ secrets.GITHUBTOKEN }} environment_name: 'production'
deploy: needs: check-environment runs-on: ubuntu-latest steps: - name: Deploy to production run: echo "Deploying to production environment" ```
Error Handling
The action fails with the following errors: - 404 Not Found: If the specified environment does not exist. - 403 Forbidden: If the GitHub token provided does not have sufficient permissions to read the environment. - No Protection Rules: If the environment exists but has no protection rules configured.
Permissions
To use this action, ensure that the GITHUB_TOKEN or any custom token provided has the following permissions:
- actions: read
- contents: read
- deployments: read
You can configure these permissions explicitly in your workflow file:
yaml
permissions:
actions: read
contents: read
deployments: read
License
This project is licensed under the MIT License. See the LICENSE file for details.
Owner
- Name: David Vreony
- Login: dpvreony
- Kind: user
- Location: UK
- Website: http://www.dpvreony.co.uk
- Repositories: 39
- Profile: https://github.com/dpvreony
.NET Developer \ Analyst \ Architect with experience in Developer Experience, Financial Services and Healthcare domains
GitHub Events
Total
- Issues event: 1
- Delete event: 3
- Push event: 12
- Pull request review event: 2
- Pull request event: 4
- Create event: 5
Last Year
- Issues event: 1
- Delete event: 3
- Push event: 12
- Pull request review event: 2
- Pull request event: 4
- Create event: 5
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 1
- Total pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 11 minutes
- Total issue authors: 1
- Total pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 1
- Bot pull requests: 2
Past Year
- Issues: 1
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 11 minutes
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 1
- Bot pull requests: 2
Top Authors
Issue Authors
- renovate[bot] (1)
Pull Request Authors
- dpvreony (2)
- renovate[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- ./ * composite
- actions/checkout v4 composite