Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/check-cr-approved.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
echo "Running on PR #$PR_NUMBER in Repository $REPO"

# -- 1. Extract the assigned Code Reviewer from the PR body
CODE_REVIEWER=$(echo "$PR_BODY" | grep -oP "Code Reviewer:\s?@\K([a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38})") || true

Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/cla-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ jobs:
id: check_contributor_base
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
if [ -f "CONTRIBUTORS" ]; then
if grep -q "^$AUTHOR" CONTRIBUTORS; then
if [ -f "CONTRIBUTORS.md" ]; then
if grep -qE "\|\s*$AUTHOR" CONTRIBUTORS.md; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you not want to check for the extra spaces after $AUTHOR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

echo "on_base=true" >> $GITHUB_OUTPUT
echo "🎉 $AUTHOR has already signed the CLA on base branch."
else
echo "on_base=false" >> $GITHUB_OUTPUT
echo "⚠️ $AUTHOR not on base. Proceeding to check PR branch."
fi
else
# If CONTRIBUTORS file doesn't exist, we must check PR branch
# If CONTRIBUTORS.md file doesn't exist, we must check PR branch
echo "on_base=undefined" >> $GITHUB_OUTPUT
echo "🔴 CONTRIBUTORS file does not exist on base. Proceeding to check PR branch."
echo "🔴 CONTRIBUTORS.md file does not exist on base. Proceeding to check PR branch."
fi

# --- Step 2: Check PR Branch ---
Expand All @@ -56,9 +56,9 @@ jobs:
if: steps.check_contributor_base.outputs.on_base != 'true'
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
if grep -q "^$AUTHOR" CONTRIBUTORS; then
if grep -q "\|\s*$AUTHOR" CONTRIBUTORS.md; then
echo "signed=true" >> $GITHUB_OUTPUT
echo "✅ $AUTHOR has updated their CLA signature in CONTRIBUTORS file."
echo "✅ $AUTHOR has updated their CLA signature in CONTRIBUTORS.md file."
else
echo "signed=false" >> $GITHUB_OUTPUT
echo "❌ $AUTHOR has not signed the CLA."
Expand Down Expand Up @@ -124,11 +124,11 @@ jobs:
]);

// Post CLA comment
const commentBody = `Hello @${author}! 👋\n\nThank you for your contribution. Since this is your first time contributing to this repository, we ask that you sign our Contributor Licence Agreement (CLA).\n\n📄 [You can read the CLA here](https://github.com/MetOffice/simulation-systems/blob/github_wps/Momentum-CLA.md).\n\nTo agree to the CLA, please add your details (**GitHub username**, real name, organisation, email, and date) to the _CONTRIBUTORS_ file (create one, if required) in the development branch for this PR. After signing the CLA, you won't need to do this again for future PRs.`;
const commentBody = `Hello @${author}! 👋\n\nThank you for your contribution. Since this is your first time contributing to this repository, we ask that you sign our Contributor Licence Agreement (CLA).\n\n📄 [You can read the CLA here](https://github.com/MetOffice/Momentum/blob/main/CLA.md).\n\nTo agree to the CLA, please add your details (**GitHub username**, Real Name, Affiliation, and Date) to the _CONTRIBUTORS.md_ file (create one, if required) in the development branch for this PR. After signing the CLA, you won't need to do this again for future PRs.`;

await github.rest.issues.createComment({ owner, repo, issue_number, body: commentBody });

// Fail the GitHub Action run
console.error("⚠️ Please add yourself to the CONTRIBUTORS file to sign the CLA.");
console.error("⚠️ Please add yourself to the CONTRIBUTORS.md file to sign the CLA.");
process.exit(1);
}