Skip to content

Instantly share code, notes, and snippets.

@tomkerkhove
Created February 10, 2022 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomkerkhove/ae343f64e2a711e227d5bae43134b858 to your computer and use it in GitHub Desktop.
Save tomkerkhove/ae343f64e2a711e227d5bae43134b858 to your computer and use it in GitHub Desktop.
name: Add issue to project
on:
issues:
types:
- opened
jobs:
track_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{ secrets.AUTH }}
USER: tomkerkhove
PROJECT_NUMBER: 3
run: |
gh api graphql -f query='
query($user: String!, $number: Int!) {
user(login: $user){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f user=$USER -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.user.projectNext.id' project_data.json) >> $GITHUB_ENV
- name: Display the path
run: cat project_data.json
shell: bash
- name: Add issue to project
env:
GITHUB_TOKEN: ${{ secrets.AUTH }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $issue}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment