Skip to content

[AV-128953] Add acceptance tests for data management resources #1249

[AV-128953] Add acceptance tests for data management resources

[AV-128953] Add acceptance tests for data management resources #1249

Workflow file for this run

name: "Label PR Based on Template"
on:
pull_request:
jobs:
label-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- name: Check PR body
id: check-pr
run: |
if [ -z "${{ github.event.pull_request.body }}" ]; then
echo "PR body is empty. Please fill out the PR template."
exit 1
fi
- name: Extract and set labels based on PR body
id: get-labels
run: |
echo "PR_BODY<<EOF" >> $GITHUB_ENV
echo "${{ github.event.pull_request.body }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Debug: Show PR body
echo "PR Body content:"
echo "${{ github.event.pull_request.body }}"
- name: Determine which labels to apply
id: determine-labels
run: |
declare -a LABELS=()
echo "Checking PR body content for matches..."
# Core changes
if echo "${{ env.PR_BODY }}" | grep -iq "\[[xX]\] Bug fix"; then
echo "Found Bug fix checkbox"
LABELS+=("bug")
fi
if echo "${{ env.PR_BODY }}" | grep -iq "\[[xX]\] New feature"; then
echo "Found New feature checkbox"
LABELS+=("enhancement")
fi
if echo "${{ env.PR_BODY }}" | grep -iq "\[[xX]\] Breaking change"; then
echo "Found Breaking change checkbox"
LABELS+=("breaking change")
fi
# Documentation
if echo "${{ env.PR_BODY }}" | grep -iq "\[[xX]\] Documentation"; then
echo "Found Documentation checkbox"
LABELS+=("documentation")
fi
# ci/cd
if echo "${{ env.PR_BODY }}" | grep -iq "\[[xX]\] This change updates the ci/cd workflow"; then
echo "Found ci/cd workflow checkbox"
LABELS+=("ci/cd")
fi
# Debug: Show what was found
echo "Content of LABELS array:"
printf '%s\n' "${LABELS[@]}"
# Output the labels
if [ ${#LABELS[@]} -eq 0 ]; then
echo "No labels found, setting needs-triage"
echo "labels=needs-triage" >> $GITHUB_OUTPUT
else
echo "Found labels, joining them"
IFS=,
echo "labels=${LABELS[*]}" >> $GITHUB_OUTPUT
fi
# Debug output
echo "Final labels output: $(cat $GITHUB_OUTPUT)"
- name: Add labels
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = '${{ steps.determine-labels.outputs.labels }}'.split(',');
console.log('PR Body:', context.payload.pull_request.body);
console.log('Adding labels:', labels);
try {
await github.rest.issues.addLabels({
...context.repo,
issue_number: context.payload.pull_request.number,
labels: labels
});
console.log('Successfully added labels');
} catch (error) {
console.log('Error adding labels:', error);
throw error;
}
- name: Add comment if no template matches found
if: steps.determine-labels.outputs.labels == 'needs-triage'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: 'No PR template selections were detected. Please make sure to fill out the PR template properly by selecting the appropriate checkboxes.'
});