|
1 | | -name: PR Labels |
2 | | - |
3 | | -on: |
4 | | - pull_request: |
5 | | - types: [opened, reopened, synchronize, labeled, unlabeled] # Trigger on these PR activities |
6 | | - |
7 | | -jobs: |
8 | | - check_changelog_label: |
9 | | - name: Validate Changelog Label |
10 | | - runs-on: ubuntu-latest |
11 | | - permissions: |
12 | | - pull-requests: read # Grant permission to read PR information |
13 | | - steps: |
14 | | - - name: Get PR Labels from API |
15 | | - id: get_labels_api |
16 | | - uses: octokit/[email protected] # Use an action to make API requests |
17 | | - with: |
18 | | - route: GET /repos/{owner}/{repo}/issues/{pull_number}/labels |
19 | | - owner: ${{ github.repository_owner }} |
20 | | - repo: ${{ github.event.repository.name }} |
21 | | - pull_number: ${{ github.event.pull_request.number }} |
22 | | - env: |
23 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token |
24 | | - |
25 | | - - name: Extract and Check Labels |
26 | | - env: |
27 | | - API_RESPONSE: ${{ steps.get_labels_api.outputs.data }} |
28 | | - run: | |
29 | | - REQUIRED_LABELS=( |
30 | | - "chore" |
31 | | - "bug" |
32 | | - "feature" |
33 | | - "fix" |
34 | | - "performance" |
35 | | - "break" |
36 | | - "wire-break" |
37 | | - ) |
38 | | - REQUIRED_LABELS_JSON=$(jq -n '$ARGS.positional' --args "${REQUIRED_LABELS[@]}") |
39 | | - echo "Required Labels: $REQUIRED_LABELS_JSON" |
40 | | -
|
41 | | - # Parse the response from the API call |
42 | | - # The API returns an array of label objects, we need just the 'name' property |
43 | | - echo "API Response: $API_RESPONSE" |
44 | | -
|
45 | | - # Extract only the label names into a JSON array |
46 | | - CURRENT_PR_LABELS_JSON=$(echo "$API_RESPONSE" | jq '[.[] | .name]') |
47 | | - echo "Current PR Labels from API: $CURRENT_PR_LABELS_JSON" |
48 | | -
|
49 | | - found_one=false |
50 | | - for label in "${REQUIRED_LABELS[@]}"; do |
51 | | - if echo "$CURRENT_PR_LABELS_JSON" | jq -e --arg label "$label" 'contains([$label])'; then |
52 | | - echo "Found required label: $label" |
53 | | - found_one=true |
54 | | - break |
55 | | - fi |
56 | | - done |
57 | | -
|
58 | | - if [ "$found_one" = false ]; then |
59 | | - echo "::error file=.github/workflows/pr-labels.yml::Pull Request is missing a required changelog label. Please add one of: ${REQUIRED_LABELS[*]}." |
60 | | - exit 1 |
61 | | - else |
62 | | - echo "Pull Request has a required changelog label." |
63 | | - fi |
| 1 | +## Note: Disable our internal vortex to pass CI |
| 2 | +#name: PR Labels |
| 3 | +# |
| 4 | +#on: |
| 5 | +# pull_request: |
| 6 | +# types: [opened, reopened, synchronize, labeled, unlabeled] # Trigger on these PR activities |
| 7 | +# |
| 8 | +#jobs: |
| 9 | +# check_changelog_label: |
| 10 | +# name: Validate Changelog Label |
| 11 | +# runs-on: ubuntu-latest |
| 12 | +# permissions: |
| 13 | +# pull-requests: read # Grant permission to read PR information |
| 14 | +# steps: |
| 15 | +# - name: Get PR Labels from API |
| 16 | +# id: get_labels_api |
| 17 | +# uses: octokit/[email protected] # Use an action to make API requests |
| 18 | +# with: |
| 19 | +# route: GET /repos/{owner}/{repo}/issues/{pull_number}/labels |
| 20 | +# owner: ${{ github.repository_owner }} |
| 21 | +# repo: ${{ github.event.repository.name }} |
| 22 | +# pull_number: ${{ github.event.pull_request.number }} |
| 23 | +# env: |
| 24 | +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token |
| 25 | +# |
| 26 | +# - name: Extract and Check Labels |
| 27 | +# env: |
| 28 | +# API_RESPONSE: ${{ steps.get_labels_api.outputs.data }} |
| 29 | +# run: | |
| 30 | +# REQUIRED_LABELS=( |
| 31 | +# "chore" |
| 32 | +# "bug" |
| 33 | +# "feature" |
| 34 | +# "fix" |
| 35 | +# "performance" |
| 36 | +# "break" |
| 37 | +# "wire-break" |
| 38 | +# ) |
| 39 | +# REQUIRED_LABELS_JSON=$(jq -n '$ARGS.positional' --args "${REQUIRED_LABELS[@]}") |
| 40 | +# echo "Required Labels: $REQUIRED_LABELS_JSON" |
| 41 | +# |
| 42 | +# # Parse the response from the API call |
| 43 | +# # The API returns an array of label objects, we need just the 'name' property |
| 44 | +# echo "API Response: $API_RESPONSE" |
| 45 | +# |
| 46 | +# # Extract only the label names into a JSON array |
| 47 | +# CURRENT_PR_LABELS_JSON=$(echo "$API_RESPONSE" | jq '[.[] | .name]') |
| 48 | +# echo "Current PR Labels from API: $CURRENT_PR_LABELS_JSON" |
| 49 | +# |
| 50 | +# found_one=false |
| 51 | +# for label in "${REQUIRED_LABELS[@]}"; do |
| 52 | +# if echo "$CURRENT_PR_LABELS_JSON" | jq -e --arg label "$label" 'contains([$label])'; then |
| 53 | +# echo "Found required label: $label" |
| 54 | +# found_one=true |
| 55 | +# break |
| 56 | +# fi |
| 57 | +# done |
| 58 | +# |
| 59 | +# if [ "$found_one" = false ]; then |
| 60 | +# echo "::error file=.github/workflows/pr-labels.yml::Pull Request is missing a required changelog label. Please add one of: ${REQUIRED_LABELS[*]}." |
| 61 | +# exit 1 |
| 62 | +# else |
| 63 | +# echo "Pull Request has a required changelog label." |
| 64 | +# fi |
0 commit comments