At the leader #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on: | |
# schedule: | |
# - cron: "0 4 * * 2" | |
name: start-community-sync-discussion | |
# TODO allow running on demand as well while manually populating fields. | |
# This should override the current comment if it exists. | |
env: | |
GH_TOKEN: ${{ github.token }} | |
leader: errose28 | |
title: Test Community Discussion for <date> | |
leader_template: <leader> | |
date_template: <date> | |
body: | | |
Hi @<leader> | |
This is a test discussion for a community sync. | |
on: | |
push | |
jobs: | |
start-community-sync-discussion: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get repo ID | |
run: | | |
repo_id="$(gh api graphql --jq='.data.repository.id' -f query='query { | |
repository(owner: "errose28", name: "ozone") { | |
id | |
} | |
}')" | |
echo REPO_ID="$repo_id" >> $GITHUB_ENV | |
- name: Get category ID | |
run: | | |
category_id="$(gh api graphql --jq='.data.repository.discussionCategories.nodes[] | | |
select(.name == "Community Sync Meetings") | .id' -f query='query { repository(owner: "errose28", name: "ozone") { | |
discussionCategories(first: 100) { | |
nodes {id name} | |
} | |
} | |
}')" | |
echo CATEGORY_ID="$category_id" >> $GITHUB_ENV | |
- name: Substitute current leader | |
run: | | |
body_with_name="$(echo '${{ env.body }}' | sed 's/${{ env.leader_template }}/${{ env.leader }}/g')" | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | |
{ | |
echo 'BODY_WITH_NAME<<EOF' | |
echo "$body_with_name" | |
echo EOF | |
} >> "$GITHUB_ENV" | |
- name: Substitute current date | |
run: | | |
date="$(date '+%a %b %-e %-l:%M%#p')" | |
title_with_date="$(echo '${{ env.title }}' | sed "s/${{ env.date_template }}/$date/g")" | |
echo TITLE_WITH_DATE="$title_with_date" >> $GITHUB_ENV | |
- name: Post discussion | |
run: | | |
url="$(gh api graphql --jq='.data.createDiscussion.discussion.url' -f query='mutation { | |
createDiscussion( | |
input: { | |
repositoryId: "${{ env.REPO_ID }}", | |
categoryId: "${{ env.CATEGORY_ID }}", | |
title: "${{ env.TITLE_WITH_DATE }}", | |
body: "${{ env.BODY_WITH_NAME }}"}) | |
{ | |
discussion { | |
url | |
} | |
} | |
}')" | |
echo "GitHub Discussion for community sync created at $url" | tee -a "$GITHUB_STEP_SUMMARY" |