Skip to content

Bump foss project references. #3608

Bump foss project references.

Bump foss project references. #3608

name: practices/check-pr
on:
pull_request:
types: [opened, edited, reopened, synchronize, labeled, unlabeled, edited, assigned, unassigned ]
jobs:
check-pr:
runs-on: ubuntu-latest
steps:
- name: Generate token from Duende GitHub Bot
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.DUENDE_GITHUB_BOT_APP_ID }}
private-key: ${{ secrets.DUENDE_GITHUB_BOT_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Check PR title and labels
uses: actions/github-script@v7
with:
script: |
const prTitle = context.payload.pull_request.title;
const branchName = context.payload.pull_request.head.ref;
// Normalize branch name and PR title by replacing slashes and hyphens with spaces, and convert to lowercase
const normalizeString = (str) => str.replace(/[-\/]/g, ' ').toLowerCase();
const normalizedPrTitle = normalizeString(prTitle);
const normalizedBranchName = normalizeString(branchName);
// Check if the PR title is the same as the branch name
if (normalizedPrTitle === normalizedBranchName) {
core.setFailed('PR title should not be the same as the branch name. Please provide a more descriptive title.');
} else {
console.log('PR title check passed.');
}
if (context.payload.pull_request.labels.length === 0) {
core.setFailed(`This pull request does not have any labels. Please set the 'area' and 'impact' and any relavent others.`);
} else {
console.log('PR label check passed.');
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check PR assignee
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
if (pr.assignees.length === 0) {
core.setFailed(`This pull request does not have any assignees. The assignee is responsible for merging, please set one.`);
} else {
console.log('PR assignee check passed.');
}
- name: Check for linked issues in Development section
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
echo "Checking PR #${{ github.event.pull_request.number }} for linked issues..."
# Get linked issues from the Development section
LINKED_ISSUES=$(gh pr view ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--json closingIssuesReferences \
--jq '.closingIssuesReferences | length')
echo "Found $LINKED_ISSUES linked issue(s)"
if [ "$LINKED_ISSUES" -eq 0 ]; then
echo "::error::This PR must have at least one issue linked in the Development section."
echo "::error::Please link an issue by adding it to the Development section on the right side of the PR page."
echo "::error::After linking an issue, manually re-run this check from the Actions tab or push a new commit."
exit 1
fi
echo "✓ PR has linked issues in Development section"