Skip to content

Commit 3b3f3e5

Browse files
authored
Merge pull request #203 from OAI/ci/multiple-discussions
ci/multiple discussions
2 parents 03bc96e + 1f2af9f commit 3b3f3e5

File tree

1 file changed

+46
-12
lines changed

1 file changed

+46
-12
lines changed

.github/workflows/agenda.yaml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
permissions:
1212
discussions: write
1313
runs-on: ubuntu-22.04
14+
env:
15+
CATEGORY_ID: 'DIC_kwDOFXMeLs4COVB8'
16+
REPOSITORY_ID: 'MDEwOlJlcG9zaXRvcnkzNTk4NjU5MDI='
1417
steps:
1518
- uses: actions/checkout@v5
1619
- name: Check if it's an alternate week
@@ -39,24 +42,55 @@ jobs:
3942
run: |
4043
NEXT_MEETING_DATE=$(date -d "next Tuesday" +%Y-%m-%d)
4144
echo "NEXT_MEETING_DATE=$NEXT_MEETING_DATE" >> $GITHUB_ENV
42-
- name: Create discussion with agenda
45+
- name: Define discussion title
46+
if: steps.check-week.outputs.should_run == 'true'
47+
id: define-title
48+
run: |
49+
DISCUSSION_TITLE="Overlays Meeting (${{ env.NEXT_MEETING_DATE }})"
50+
echo "DISCUSSION_TITLE=$DISCUSSION_TITLE" >> $GITHUB_ENV
51+
- name: Search for existing discussion
4352
if: steps.check-week.outputs.should_run == 'true'
53+
id: search-discussion
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
FOUND_DISCUSSION_TITLE=$(gh api graphql -f query='
58+
query SearchDiscussionMutation ($repositoryOwner: String!, $repositoryName: String!, $categoryId: ID!) {
59+
repository(owner: $repositoryOwner, name: $repositoryName) {
60+
discussions(first: 1, orderBy: {direction: DESC, field: CREATED_AT}, categoryId: $categoryId) {
61+
nodes {
62+
title
63+
}
64+
}
65+
}
66+
}' \
67+
-f repositoryOwner="${{ github.repository_owner }}" \
68+
-f repositoryName="${{ github.event.repository.name }}" \
69+
-f categoryId="${{ env.CATEGORY_ID }}" \
70+
--jq '.data.repository.discussions.nodes[0].title')
71+
if [ "$FOUND_DISCUSSION_TITLE" = "${{ env.DISCUSSION_TITLE }}" ]; then
72+
DISCUSSION_COUNT=1
73+
else
74+
DISCUSSION_COUNT=0
75+
fi
76+
echo "DISCUSSION_COUNT=$DISCUSSION_COUNT" >> $GITHUB_OUTPUT
77+
echo "Found $DISCUSSION_COUNT existing discussions"
78+
- name: Create discussion with agenda
79+
if: steps.check-week.outputs.should_run == 'true' && steps.search-discussion.outputs.DISCUSSION_COUNT == '0'
4480
id: create-repository-discussion
45-
uses: octokit/[email protected]
4681
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
with:
49-
variables: |
50-
body: "${{ env.AGENDA }}"
51-
title: "Overlays Meeting (${{ env.NEXT_MEETING_DATE }})"
52-
repositoryId: 'MDEwOlJlcG9zaXRvcnkzNTk4NjU5MDI='
53-
categoryId: 'DIC_kwDOFXMeLs4COVB8'
54-
query: |
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
gh api graphql -f query='
5585
mutation CreateDiscussionMutation ($title: String!, $body: String!, $repositoryId: ID!, $categoryId: ID!) {
5686
createDiscussion(input: { title: $title, body: $body, repositoryId: $repositoryId, categoryId: $categoryId }) {
5787
discussion {
5888
title
89+
url
5990
}
6091
}
61-
}
62-
92+
}' \
93+
-f title="${{ env.DISCUSSION_TITLE }}" \
94+
-f body="${{ env.AGENDA }}" \
95+
-f repositoryId="${{ env.REPOSITORY_ID }}" \
96+
-f categoryId="${{ env.CATEGORY_ID }}"

0 commit comments

Comments
 (0)