-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32605 from hashicorp/m-actions-labels
Rework Labeling & Project Automation Workflows
- Loading branch information
Showing
21 changed files
with
572 additions
and
331 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
PROJECT_NUMBER=196 | ||
PROJECT_ID="PVT_kwDOAAuecM4AF-7h" | ||
|
||
main () { | ||
ISSUES=$(gh api graphql --paginate -F milestone="$MILESTONE" -f query=' | ||
query($milestone: Int!, $endCursor: String) { | ||
organization(login: "hashicorp") { | ||
repository(name: "terraform-provider-aws") { | ||
milestone(number: $milestone) { | ||
issues(first: 10, after: $endCursor) { | ||
edges { | ||
node { | ||
id | ||
projectItems(includeArchived: false, first: 10) { | ||
nodes { | ||
id | ||
project { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' --jq '.data.organization.repository.milestone.issues.edges[].node.projectItems.nodes[]' | jq --slurp '. | tojson') | ||
|
||
PULLS=$(gh api graphql --paginate -F milestone="$MILESTONE" -f query=' | ||
query($milestone: Int!, $endCursor: String) { | ||
organization(login: "hashicorp") { | ||
repository(name: "terraform-provider-aws") { | ||
milestone(number: $milestone) { | ||
pullRequests(first: 10, after: $endCursor) { | ||
edges { | ||
node { | ||
id | ||
projectItems(includeArchived: false, first: 10) { | ||
nodes { | ||
id | ||
project { | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' --jq '.data.organization.repository.milestone.pullRequests.edges[].node.projectItems.nodes[]' | jq --slurp '. | tojson') | ||
|
||
PROJECT_ITEMS=$(jq \ | ||
--null-input \ | ||
--arg project "$PROJECT_ID" \ | ||
--argjson issues "$ISSUES" \ | ||
--argjson pulls "$PULLS" \ | ||
'$issues, $pulls | fromjson | .[] | select(.project.id == $project).id') | ||
|
||
for item in $PROJECT_ITEMS; do | ||
echo "Archiving $item" | ||
gh project item-archive "$PROJECT_NUMBER" --owner "hashicorp" --id "$item" | ||
done | ||
} | ||
|
||
main |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
main () { | ||
ISSUES=$(gh api graphql --paginate -F milestone="$MILESTONE" -f query=' | ||
query($milestone: Int!, $endCursor: String) { | ||
organization(login: "hashicorp") { | ||
repository(name: "terraform-provider-aws") { | ||
milestone(number: $milestone) { | ||
issues(first: 10, after: $endCursor, labels: ["prioritized"]) { | ||
edges { | ||
node { | ||
url | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' --jq '.data.organization.repository.milestone.issues.edges[].node' | jq --raw-output --slurp '[.[].url] | join(" ")') | ||
|
||
PULLS=$(gh api graphql --paginate -F milestone="$MILESTONE" -f query=' | ||
query($milestone: Int!, $endCursor: String) { | ||
organization(login: "hashicorp") { | ||
repository(name: "terraform-provider-aws") { | ||
milestone(number: $milestone) { | ||
pullRequests(first: 10, after: $endCursor, labels: ["prioritized"]) { | ||
edges { | ||
node { | ||
url | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}' --jq '.data.organization.repository.milestone.pullRequests.edges[].node' | jq --raw-output --slurp '.[] | .url') | ||
|
||
# gh issues allows passing multiple URLs at once | ||
gh issue edit $ISSUES --remove-label bug | ||
|
||
# gh pr does not allow passing multiple URLs at once | ||
for item in $PULLS; do | ||
gh pr edit "$item" --remove-label bug | ||
done | ||
} | ||
|
||
main |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'Process issue_comment Events' | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
community_check: | ||
name: 'Community Check' | ||
uses: ./.github/workflows/community-check.yml | ||
secrets: inherit | ||
with: | ||
username: ${{ github.event.comment.user.login }} | ||
|
||
automation_labeler: | ||
name: 'Automation Labeler' | ||
needs: community_check | ||
runs-on: ubuntu-latest | ||
env: | ||
# This is a ternary that sets the variable to the assigned user's login on assigned events, | ||
# and otherwise sets it to the username of the pull request's author. For more information: | ||
# https://docs.github.com/en/actions/learn-github-actions/expressions#example | ||
# | ||
# issue_comment events are triggered by comments on issues and pull requests. Checking the | ||
# value of github.event.issue.pull_request tells us whether the issue is an issue or is | ||
# actually a pull request, allowing us to dynamically set the gh subcommand: | ||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only | ||
COMMAND: ${{ github.event.issue.pull_request && 'pr' || 'issue' }} | ||
GH_TOKEN: ${{ github.token }} | ||
steps: | ||
- name: 'Remove stale and waiting-response on non-maintainer comment' | ||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only | ||
run: gh ${{ env.COMMAND }} edit ${{ github.event.issue.html_url }} --remove-label stale,waiting-response |
Oops, something went wrong.