Skip to content

Commit 1fc858b

Browse files
workflow: add issue to project
Changes to be committed: new file: add-issue-to-project/add_issue_to_project.sh new file: add_issue_to_project.yml
1 parent a8e07c5 commit 1fc858b

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
OWNER="ilkermeliksitki"
4+
REPO="german-dict"
5+
PROJECT=5
6+
7+
echo "Syncing issues from $OWNER/$REPO into project #$PROJECT..."
8+
9+
# get all issues in the repo
10+
ISSUES=$(gh issue list --repo "$OWNER/$REPO" --limit 10000 --state open --json number,url -q '.[] | {number, url}')
11+
12+
# get all issues already in the project
13+
EXISTING=$(gh project item-list "$PROJECT" --owner "$OWNER" --limit 10000 --format json | jq '.items[].content.url')
14+
15+
echo "$ISSUES" | jq -c '.' | while read -r issue; do
16+
URL=$(echo "$issue" | jq -r '.url')
17+
NUM=$(echo "$issue" | jq -r '.number')
18+
19+
if echo "$EXISTING" | grep -q "$URL"; then
20+
echo "✅ Issue $URL, #$NUM already in project"
21+
else
22+
echo "➕ Adding issue $URL to project"
23+
gh project item-add "$PROJECT" --owner "$OWNER" --url "$URL"
24+
fi
25+
done
26+
27+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Add issue to project automation
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
workflow_dispatch:
7+
8+
jobs:
9+
on_issue_opened:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
15+
- name: Add issue to project
16+
run: |
17+
bash .github/workflows/add-issue-to-project/add_issue_to_project.sh
18+
env:
19+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
20+

0 commit comments

Comments
 (0)