forked from OAI/Overlay-Specification
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (134 loc) · 5.31 KB
/
agenda.yaml
File metadata and controls
141 lines (134 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Create meeting template
on:
workflow_dispatch: {}
schedule:
# every week on tuesday at 10AM PST (with DST)
- cron: '0 17 * * 2'
jobs:
get-next-dates:
if: github.repository == 'OAI/Overlay-Specification'
permissions: {}
runs-on: ubuntu-22.04
outputs:
meeting_dates: ${{ steps.get-next-meeting-dates.outputs.MEETING_DATES }}
env:
NUMBER_OF_INSTANCES: 2
MEETING_INTERVAL_WEEKS: 2
steps:
- name: Check if it's an alternate week
id: check-week
run: |
# Get ISO week number (1-53)
WEEK_NUMBER=$(date +%V)
# Check if week number is odd or even to run workflow and create agenda for next week's meeting
if [ $((WEEK_NUMBER % 2)) -eq 0 ]; then
echo "Should run this week (even week: $WEEK_NUMBER)"
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "Skipping odd week: $WEEK_NUMBER"
echo "should_run=false" >> $GITHUB_OUTPUT
fi
- name: Get Next Meeting Dates
id: get-next-meeting-dates
env:
SHOULD_RUN: ${{ steps.check-week.outputs.should_run }}
run: |
if [ "$SHOULD_RUN" != "true" ]; then
echo "MEETING_DATES=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Generate multiple meeting dates based on NUMBER_OF_INSTANCES
MEETING_DATES="["
for i in $(seq 1 $NUMBER_OF_INSTANCES); do
# Calculate the date for the i-th Tuesday from now
# For i=1, get next Tuesday; for i=2, get Tuesday after next, etc.
WEEKS_AHEAD=$(((i - 1)*MEETING_INTERVAL_WEEKS))
if [ $i -eq 1 ]; then
DATE_CMD="next Tuesday"
else
DATE_CMD="next Tuesday +${WEEKS_AHEAD} weeks"
fi
MEETING_DATE=$(date -d "$DATE_CMD" +%Y-%m-%d)
if [ $i -eq 1 ]; then
MEETING_DATES="$MEETING_DATES\"$MEETING_DATE\""
else
MEETING_DATES="$MEETING_DATES,\"$MEETING_DATE\""
fi
done
MEETING_DATES="$MEETING_DATES]"
echo "MEETING_DATES=$MEETING_DATES" >> $GITHUB_OUTPUT
create-discussion:
if: github.repository == 'OAI/Overlay-Specification' && needs.get-next-dates.outputs.meeting_dates != '[]'
needs: get-next-dates
strategy:
matrix:
next_meeting_date: ${{ fromJson(needs.get-next-dates.outputs.meeting_dates) }}
runs-on: ubuntu-22.04
env:
CATEGORY_ID: 'DIC_kwDOFXMeLs4COVB8'
REPOSITORY_ID: 'MDEwOlJlcG9zaXRvcnkzNTk4NjU5MDI='
permissions:
discussions: write
contents: read
steps:
- uses: actions/checkout@v6
- name: Get agenda text from template
id: get-agenda
run: |
echo 'AGENDA<<EOF' >> $GITHUB_ENV
cat .github/templates/agenda.md >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Define discussion title
id: define-title
run: |
DISCUSSION_TITLE="Overlays Meeting (${{ matrix.next_meeting_date }})"
echo "DISCUSSION_TITLE=$DISCUSSION_TITLE" >> $GITHUB_ENV
- name: Search for existing discussion
id: search-discussion
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FOUND_DISCUSSIONS=$(gh api graphql -f query='
query SearchDiscussionMutation ($repositoryOwner: String!, $repositoryName: String!, $categoryId: ID!) {
repository(owner: $repositoryOwner, name: $repositoryName) {
discussions(first: 10, orderBy: {direction: DESC, field: CREATED_AT}, categoryId: $categoryId) {
nodes {
title
}
}
}
}' \
-f repositoryOwner="${{ github.repository_owner }}" \
-f repositoryName="${{ github.event.repository.name }}" \
-f categoryId="${{ env.CATEGORY_ID }}" \
--jq '.data.repository.discussions.nodes[].title')
DISCUSSION_COUNT=0
TARGET_TITLE="${{ env.DISCUSSION_TITLE }}"
# Iterate through all returned discussion titles
while IFS= read -r discussion_title; do
if [ "$discussion_title" = "$TARGET_TITLE" ]; then
DISCUSSION_COUNT=1
break
fi
done <<< "$FOUND_DISCUSSIONS"
echo "DISCUSSION_COUNT=$DISCUSSION_COUNT" >> $GITHUB_OUTPUT
echo "Found $DISCUSSION_COUNT existing discussions with title: $TARGET_TITLE"
- name: Create discussion with agenda
if: steps.search-discussion.outputs.DISCUSSION_COUNT == '0'
id: create-repository-discussion
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api graphql -f query='
mutation CreateDiscussionMutation ($title: String!, $body: String!, $repositoryId: ID!, $categoryId: ID!) {
createDiscussion(input: { title: $title, body: $body, repositoryId: $repositoryId, categoryId: $categoryId }) {
discussion {
title
url
}
}
}' \
-f title="${{ env.DISCUSSION_TITLE }}" \
-f body="${{ env.AGENDA }}" \
-f repositoryId="${{ env.REPOSITORY_ID }}" \
-f categoryId="${{ env.CATEGORY_ID }}"