Created
February 10, 2022 10:27
-
-
Save tomkerkhove/ae343f64e2a711e227d5bae43134b858 to your computer and use it in GitHub Desktop.
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 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