|
3 | 3 | # |
4 | 4 | # This action runs every time a PR is updated & prepares it for CI. |
5 | 5 | # CI checks pull requests that are labeled 'needs_ci' and runs unit tests and lint. |
| 6 | +# - If the 'needs_ci' label is present, no additional labels are added. |
| 7 | +# - If the 'shipit' label is present, it ensures the 'needs_ci' label is added. |
| 8 | +# - If neither 'needs_ci' nor 'shipit' are present, it adds the 'needs_ci:lite' label. |
| 9 | +# - If 'ci_verified' label is present, it removes 'ci_verified' and adds 'needs_ci'. |
| 10 | +# - If 'ci_verified:lite' label is present, it removes 'ci_verified:lite' and adds 'needs_ci:lite'. |
6 | 11 |
|
7 | 12 | set -e |
8 | 13 |
|
@@ -34,16 +39,10 @@ draft=$(jq --raw-output .pull_request.draft "$GITHUB_EVENT_PATH") |
34 | 39 | echo $title |
35 | 40 | echo $draft |
36 | 41 |
|
37 | | -has_hotfix_label=false |
38 | | -hotfix_failed=false |
39 | | - |
40 | 42 | if [[ "$draft" == "true" ]]; then |
41 | 43 | echo "Skipping PR since it's still in draft." |
42 | 44 | exit 0 |
43 | 45 | fi |
44 | | -if [[ "$title" =~ ^HOTFIX.*$ ]]; then |
45 | | - needs_hotfix=true |
46 | | -fi |
47 | 46 |
|
48 | 47 | add_comment(){ |
49 | 48 | curl -sSL \ |
@@ -79,35 +78,49 @@ labels=$(echo "$body" | jq --raw-output '.labels[].name') |
79 | 78 |
|
80 | 79 | IFS=$'\n' |
81 | 80 |
|
| 81 | +needs_ci_label_present=false |
| 82 | +needs_ci_lite_label_present=false |
| 83 | +shipit_label_present=false |
| 84 | + |
82 | 85 | for label in $labels; do |
83 | 86 | case $label in |
84 | 87 | ci_verified) |
85 | | - echo "Removing label: $label" |
| 88 | + echo "Removing label: $label and adding needs_ci" |
86 | 89 | remove_label "$label" |
| 90 | + add_label "needs_ci" |
| 91 | + needs_ci_label_present=true |
87 | 92 | ;; |
88 | 93 | ci_verified:lite) |
89 | | - echo "Removing label: $label" |
| 94 | + echo "Removing label: $label and adding needs_ci:lite" |
90 | 95 | remove_label "$label" |
| 96 | + add_label "needs_ci:lite" |
| 97 | + needs_ci_lite_label_present=true |
91 | 98 | ;; |
92 | | - needs_hotfix) |
93 | | - echo "Setting has_hotfix_label=true" |
94 | | - has_hotfix_label=true |
| 99 | + needs_ci) |
| 100 | + echo "needs_ci label is already present" |
| 101 | + needs_ci_label_present=true |
95 | 102 | ;; |
96 | | - "hotfix:failed") |
97 | | - echo "Setting hotfix_failed=true" |
98 | | - hotfix_failed=true |
| 103 | + needs_ci:lite) |
| 104 | + echo "needs_ci:lite label is already present" |
| 105 | + needs_ci_lite_label_present=true |
| 106 | + ;; |
| 107 | + shipit) |
| 108 | + echo "shipit label is present" |
| 109 | + shipit_label_present=true |
99 | 110 | ;; |
100 | 111 | *) |
101 | 112 | echo "Unknown label $label" |
102 | 113 | ;; |
103 | 114 | esac |
104 | 115 | done |
105 | 116 |
|
106 | | -add_label "needs_ci:lite" |
107 | | - |
108 | | -if [[ ("$needs_hotfix" = true && "$has_hotfix_label" = false && "$hotfix_failed" = false) ]]; then |
109 | | - echo "Detected HOTFIX pull request that isn't already labeled." |
110 | | - add_label "needs_hotfix" |
| 117 | +if [[ "$shipit_label_present" = true ]]; then |
| 118 | + if [[ "$needs_ci_label_present" = false ]]; then |
| 119 | + add_label "needs_ci" |
| 120 | + fi |
| 121 | +elif [[ "$needs_ci_lite_label_present" = false && "$needs_ci_label_present" = false ]]; then |
| 122 | + add_label "needs_ci:lite" |
111 | 123 | fi |
112 | 124 |
|
113 | 125 | echo "Pull request passed all checkpoints!" |
| 126 | + |
0 commit comments