|
11 | 11 | permissions: |
12 | 12 | discussions: write |
13 | 13 | runs-on: ubuntu-22.04 |
| 14 | + env: |
| 15 | + CATEGORY_ID: 'DIC_kwDOFXMeLs4COVB8' |
| 16 | + REPOSITORY_ID: 'MDEwOlJlcG9zaXRvcnkzNTk4NjU5MDI=' |
14 | 17 | steps: |
15 | 18 | - uses: actions/checkout@v5 |
16 | 19 | - name: Check if it's an alternate week |
@@ -39,24 +42,55 @@ jobs: |
39 | 42 | run: | |
40 | 43 | NEXT_MEETING_DATE=$(date -d "next Tuesday" +%Y-%m-%d) |
41 | 44 | 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 |
43 | 52 | 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' |
44 | 80 | id: create-repository-discussion |
45 | | - |
46 | 81 | 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=' |
55 | 85 | mutation CreateDiscussionMutation ($title: String!, $body: String!, $repositoryId: ID!, $categoryId: ID!) { |
56 | 86 | createDiscussion(input: { title: $title, body: $body, repositoryId: $repositoryId, categoryId: $categoryId }) { |
57 | 87 | discussion { |
58 | 88 | title |
| 89 | + url |
59 | 90 | } |
60 | 91 | } |
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