1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-11-16 00:59:07 +02:00
simple-icons/.github/workflows/add-labels-priority.yml

96 lines
3.6 KiB
YAML
Raw Normal View History

name: Add Pull Request Labels and Assign to Project
on:
pull_request_target:
types: [opened, closed]
jobs:
triage:
runs-on: ubuntu-latest
if: github.event.action == 'opened'
steps:
- uses: ericcornelissen/labeler@label-based-on-status
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assign-to-project:
runs-on: ubuntu-latest
name: Assign to Project
if: github.event.action == 'opened'
needs: triage
env:
MY_GITHUB_TOKEN: ${{ secrets.AUTO_ASSIGN_WORKFLOW_TOKEN }}
steps:
- id: get-labels
name: Get labels
run: |
labels="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons/pulls/${{ github.event.pull_request.number }} | jq '.labels[].name' | tr '\n' ',' | sed -e 's/"//g' -e 's/,$//')"
echo "labels=$labels" >> $GITHUB_OUTPUT
- id: get-si-members
name: Get simple-icons members
run: |
members="$(curl -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' --retry 5 -s https://api.github.com/orgs/simple-icons/members | jq .[].login | tr '\n' ',' | sed -e 's/"//g' -e 's/,$//')"
echo "members=$members" >> $GITHUB_OUTPUT
- id: get-linked-issues
name: Get linked issue numbers
uses: mondeja/pr-linked-issues-action@v2
with:
# Lazy linked issues. If one of the lines of the pull request body
# matches one of the next contents, the matching issue number will
# be added to `issues` output:
add_links_by_content: |
**Issue:** #{issue_number}
**Issue**: #{issue_number}
**Close:** #{issue_number}
**Close**: #{issue_number}
**Closes:** #{issue_number}
**Closes**: #{issue_number}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: priority-1
name: Assign `icon outdated` pull requests to "Priority 1"
uses: srggrs/assign-one-project-github-action@1.3.1
if: contains(steps.get-labels.outputs.labels, 'icon outdated')
with:
project: https://github.com/orgs/simple-icons/projects/2
column_name: Priority 1
- id: priority-2
name: Assign `new icon` pull requests to "Priority 2"
uses: srggrs/assign-one-project-github-action@1.3.1
# the PR has the `new icon` label along with a linked issue and
# the opener is not a member of simple-icons organization
if: |
contains(steps.get-labels.outputs.labels, 'new icon') &&
join(steps.get-linked-issues.outputs.issues) != '' &&
contains(steps.get-si-members.outputs.members, github.event.pull_request.user.login) == false
with:
project: https://github.com/orgs/simple-icons/projects/2
column_name: Priority 2
- name: Assign pull requests to "Unprioritised"
uses: srggrs/assign-one-project-github-action@1.3.1
if: |
steps.priority-1.conclusion == 'skipped' &&
steps.priority-2.conclusion == 'skipped'
with:
project: https://github.com/orgs/simple-icons/projects/2
column_name: Unprioritised
unassign-from-project:
runs-on: ubuntu-latest
name: Unassign from Project
if: |
github.event.action != 'opened' &&
github.event.pull_request.merged == false
env:
MY_GITHUB_TOKEN: ${{ secrets.AUTO_ASSIGN_WORKFLOW_TOKEN }}
steps:
- name: Assign closed pull requests to "Completed or Abandoned"
uses: srggrs/assign-one-project-github-action@1.3.1
with:
project: https://github.com/orgs/simple-icons/projects/2
column_name: Completed or Abandoned