@@ -10,25 +10,43 @@ jobs:
10
10
steps :
11
11
- name : Checkout repository
12
12
uses : actions/checkout@v2
13
- - name : Add issue to project
13
+
14
+ - name : Get issue ID
15
+ id : get_issue_id
14
16
env :
15
17
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16
- DEV_PROJECT_ID : ${{ secrets.DEV_PROJECT_ID }} # Set this in your repository secrets
17
18
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='
19
21
query ($owner: String!, $name: String!, $issueNumber: Int!) {
20
22
repository(owner: $owner, name: $name) {
21
23
issue(number: $issueNumber) {
22
24
id
23
25
}
24
26
}
25
27
}' -q .data.repository.issue.id)
28
+ echo "ISSUE_ID=$issue_id" >> $GITHUB_ENV
26
29
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