Unquote issue number #33
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
name: Add issues and PRs to project | |
on: | |
issues: | |
types: | |
- opened | |
- reopened | |
- transferred | |
pull_request_target: | |
types: | |
- opened | |
- reopened | |
issue_comment: | |
types: | |
- created | |
jobs: | |
add-to-project: | |
name: Add issue to project | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get GitHub app token | |
uses: actions/create-github-app-token@v1 | |
id: app_token | |
with: | |
app-id: ${{ secrets.CONNECT_EXPORT_APP_ID }} | |
private-key: ${{ secrets.CONNECT_EXPORT_APP_KEY }} | |
- uses: actions/[email protected] | |
with: | |
project-url: https://github.com/orgs/connectrpc/projects/1 | |
github-token: ${{ steps.app_token.outputs.token }} | |
- name: Get project id if status is done | |
if: ${{ github.event_name == 'issue_comment' }} | |
id: get_project_item_id | |
env: | |
GH_TOKEN: ${{ steps.app_token.outputs.token }} | |
run: | | |
echo item_id=$(gh api graphql -f query='query ($name: String!, $owner: String!, $number: Int!) { | |
repository(name: $name, owner: $owner) { | |
name | |
issue(number: $number) { | |
projectItems(first: 100) { | |
nodes { | |
id | |
fieldValueByName(name: "Status") { | |
... on ProjectV2ItemFieldSingleSelectValue { | |
optionId | |
} | |
} | |
project { | |
number | |
} | |
} | |
} | |
} | |
} | |
}' -f name='${{ github.event.repository.name }}' -f owner='${{ github.event.repository.owner }}' -f number=${{ github.event.issue.number }} | jq -r '.data.repository.issue.projectItems.nodes | .[] | select(.project.number==1 and .fieldValueByName.optionId == "dea0b2c9") | .id') >> $GITHUB_OUTPUT | |
- name: "Update status" | |
if: ${{ steps.get_project_item_id.outputs.item_id != '' }} | |
env: | |
GH_TOKEN: ${{ steps.app_token.outputs.token }} | |
run: | | |
gh api -f query='mutation ($itemId: String!) { | |
updateProjectV2ItemFieldValue( | |
input: { | |
fieldId: "PVTSSF_lADOBcwMos4AX_p_zgPVtzo" | |
itemId: $itemId | |
projectId: "PVT_kwDOBcwMos4AX_p_" | |
value: { singleSelectOptionId: "80a785d9" } | |
} | |
) { | |
clientMutationId | |
} | |
}' -f itemId='${{ steps.get_project_item_id.outputs.item_id }}' |