60 lines
1.7 KiB
YAML
60 lines
1.7 KiB
YAML
name: Move new issue into Project
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
github-org:
|
|
type: string
|
|
default: specklesystems
|
|
description: The organisation the project belongs to
|
|
project-number:
|
|
type: number
|
|
default: 11
|
|
description: The project number where the issue should be updated
|
|
issue-id:
|
|
type: string
|
|
required: true
|
|
secrets:
|
|
GHPROJECT_TOKEN:
|
|
required: true
|
|
outputs:
|
|
item-id:
|
|
value: ${{ jobs.add-issue.outputs.item-id }}
|
|
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GHPROJECT_TOKEN }}
|
|
|
|
jobs:
|
|
track_issue:
|
|
name: Track Issue
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Get project data
|
|
run: |
|
|
gh api graphql -f query='
|
|
query ($org: String!, $number: Int!) {
|
|
organization(login: $org) {
|
|
projectV2(number: $number) {
|
|
id
|
|
}
|
|
}
|
|
}' -f org=${{ inputs.github-org }} -F number=${{ inputs.project-number }} > project_data.json
|
|
|
|
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
|
|
|
|
- id: add-issue
|
|
name: Add Issue to project
|
|
run: |
|
|
item_id="$( gh api graphql -f query='
|
|
mutation ($project: ID!, $id: ID!) {
|
|
addProjectV2ItemById(input: {projectId: $project, contentId: $id}){
|
|
item {
|
|
id
|
|
}
|
|
}
|
|
}' -f project=$PROJECT_ID -f id=${{ inputs.issue-id }} --jq '.data.addProjectV2ItemById.item.id')"
|
|
|
|
echo 'ITEM_ID='$item_id >> $GITHUB_OUTPUT
|
|
outputs:
|
|
item-id: ${{ steps.add-issue.outputs.ITEM_ID }}
|