Skip to content

Commit de98471

Browse files
authored
Update 99-add-issue-to-project.yml
1 parent dabaaf4 commit de98471

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

.github/workflows/99-add-issue-to-project.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,43 @@ jobs:
1010
steps:
1111
- name: Checkout repository
1212
uses: actions/checkout@v2
13-
- name: Add issue to project
13+
14+
- name: Get issue ID
15+
id: get_issue_id
1416
env:
1517
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16-
DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }} # Set this in your repository secrets
1718
run: |
18-
issue_node_id=$(gh api graphql -F owner='${{ github.repository_owner }}' -F name='${{ github.event.repository.name }}' -F issueNumber=${{ github.event.issue.number }} -f query='
19+
issue_number=${{ github.event.issue.number }}
20+
issue_id=$(gh api graphql -F owner='${{ github.repository_owner }}' -F name='${{ github.event.repository.name }}' -F issueNumber=$issue_number -f query='
1921
query ($owner: String!, $name: String!, $issueNumber: Int!) {
2022
repository(owner: $owner, name: $name) {
2123
issue(number: $issueNumber) {
2224
id
2325
}
2426
}
2527
}' -q .data.repository.issue.id)
28+
echo "ISSUE_ID=$issue_id" >> $GITHUB_ENV
2629
27-
gh api graphql -F projectId=$DEV_PROJECT_ID -F contentId=$issue_node_id -f query='
28-
mutation ($projectId: ID!, $contentId: ID!) {
29-
addProjectNextItem(input: {projectId: $projectId, contentId: $contentId}) {
30-
projectNextItem {
31-
id
32-
}
33-
}
34-
}'
30+
- name: Get columns in project
31+
id: get_columns
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }}
35+
run: |
36+
columns=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
37+
-H "Accept: application/vnd.github.v3+json" \
38+
"https://api.github.com/projects/$DEV_PROJECT_ID/columns")
39+
column_id=$(echo $columns | jq -r '.[] | select(.name == "No Status") | .id')
40+
echo "COLUMN_ID=$column_id" >> $GITHUB_ENV
41+
42+
- name: Add issue to project
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: |
46+
PROJECT_CARD_URL="https://api.github.com/projects/columns/$COLUMN_ID/cards"
47+
48+
# Create a project card for the issue in the specified column
49+
curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" \
50+
-H "Accept: application/vnd.github.v3+json" \
51+
$PROJECT_CARD_URL \
52+
-d '{"content_id": "'"${ISSUE_ID}"'", "content_type": "Issue"}'

0 commit comments

Comments
 (0)