Skip to content

Commit

Permalink
49 add reusable workflow to check that email used in history is gcca (#…
Browse files Browse the repository at this point in the history
…186)

* issue #49: check email author signature

* issue #49: workflow doc

* issue #49: added on push

* issue #49: test

* issue #49: test

* issue #49: changed regex expression
  • Loading branch information
ThomasCardin authored Jan 14, 2025
1 parent a90e8df commit a006dca
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/workflow-check-author-email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# GitHub Actions Workflow: Verify Committer Email for `.gc.ca` Domain

- **Purpose:** This GitHub Actions workflow ensures that commits pushed
to the repository or part of a pull request are signed with an email
address ending in `.gc.ca`. This helps verify that contributors use a
valid government email domain when committing changes.

- **Usage:** Add this workflow to your repository to enforce email validation
on all pushes and pull requests targeting the `main` branch.

- **Required Secrets:**
- `GITHUB_TOKEN`: Token for authentication with GitHub.

## Workflow Steps

1. **Checkout the Repository:**
The workflow uses the `actions/checkout@v3` action to clone the repository
into the runner's workspace.

2. **Validate Committer Email:**
The workflow leverages the `dguo/check-author-and-committer-action@v1`
action to check that the committer's email matches the specified
domain pattern (`@gc.ca`).

3. **Custom Error Messaging:**
If any commit does not meet the email criteria, a custom error message
is displayed, guiding contributors to configure their email
address correctly.
15 changes: 15 additions & 0 deletions .github/workflows/workflow-check-author-email.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Verify Committer Email

Check warning on line 1 in .github/workflows/workflow-check-author-email.yml

View workflow job for this annotation

GitHub Actions / yaml-lint-check

1:1 [document-start] missing document start "---"
on:
workflow_call:
push:

jobs:
check-commit-author:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dguo/check-author-and-committer-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
committer-email-regex: '@(?:[a-zA-Z0-9-]+\.)?gc\.ca$'
custom-error-message: "Commits must be signed with an email address ending in .gc.ca. Please configure your email address correctly."

0 comments on commit a006dca

Please sign in to comment.