Composite action versioning #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate PR Version Labels | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| validate-version-labels: | |
| name: Validate PR Version Labels | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Get all labels on the PR | |
| id: get_labels | |
| run: | | |
| SUMMARY_FILE="$GITHUB_STEP_SUMMARY" | |
| echo "## PR Labels" >> "$SUMMARY_FILE" | |
| all_labels=$(jq -r '.pull_request.labels[].name' < "$GITHUB_EVENT_PATH" 2>/dev/null || true) | |
| if [ -z "$all_labels" ]; then | |
| echo "- (none)" >> "$SUMMARY_FILE" | |
| echo "::error title=No Labels::No labels were found on this PR. A version label is required. Add version:<component>:vX.Y.Z or version:untracked." | |
| exit 1 | |
| else | |
| while IFS= read -r lbl; do | |
| [ -z "$lbl" ] && continue | |
| echo "- \`$lbl\`" >> "$SUMMARY_FILE" | |
| done <<< "$all_labels" | |
| fi | |
| # Save labels for later steps | |
| { | |
| echo "all_labels<<EOF" | |
| echo "$all_labels" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Outcome | |
| if: ${{ always() }} | |
| env: | |
| NO_LABELS: ${{ steps.get_labels.outcome == 'failure' }} | |
| run: | | |
| SUMMARY_FILE="$GITHUB_STEP_SUMMARY" | |
| echo "## Validation Outcome" >> "$SUMMARY_FILE" | |
| if [ "${{ env.NO_LABELS }}" = "true" ]; then | |
| echo "❌ No labels found on the PR. Add at least one version label." >> "$SUMMARY_FILE" | |
| fi | |
| echo "> PR must include a version label (e.g. \`version:<component>:vX.Y.Z\` or \`version:untracked\`)." >> "$SUMMARY_FILE" | |
| echo "> See Version Labeling Policy in VERSIONING.md for details." >> "$SUMMARY_FILE" | |