Update CI to use just commands rather than have 2 sets of steps that have to be in sync #279
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: Issue Labeler | |
| on: | |
| issues: | |
| types: [opened] | |
| permissions: | |
| issues: write | |
| contents: read | |
| jobs: | |
| labeler: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Check and Add label | |
| run: | | |
| # The cryptic head -c -1 is because otherwise gh always terminates output with a newline | |
| readarray -d $'\0' lifecycles < <(gh issue view ${{ github.event.issue.number }} --json labels -q '[.labels[] | .name | select(startswith("lifecycle/"))] | join("\u0000")' | head -c -1) | |
| if [[ ${#lifecycles[@]} -ne 1 ]]; then | |
| if [[ ${#lifecycles[@]} -ge 1 ]]; then | |
| echo 'Too many lifecycle labels; replacing all with `lifecycle/needs-review`' | |
| fi | |
| commands=() | |
| for label in "${lifecycles[@]}"; do | |
| if [[ "$label" != "lifecycle/needs-review" ]]; then | |
| echo "Removing label ${label}" | |
| commands+=("--remove-label" "${label}") | |
| fi | |
| done | |
| echo 'Adding `lifecycle/needs review`' | |
| commands+=("--add-label" "lifecycle/needs-review") | |
| gh issue edit ${{ github.event.issue.number }} "${commands[@]}" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |