Skip to content

Instantly share code, notes, and snippets.

@chadfawcett
Last active February 2, 2022 01:01
Show Gist options
  • Save chadfawcett/af31aa7e8b978e3c8ba9f262f4f396f7 to your computer and use it in GitHub Desktop.
Save chadfawcett/af31aa7e8b978e3c8ba9f262f4f396f7 to your computer and use it in GitHub Desktop.
Actions Workflow to automatically create a new Discussion every Friday for weekly standup.
#!/bin/bash
# script/weekly-standup.sh
# The `date` command on MacOS doesn't include the `--date` parameter, so we pass in the generated title for ease of testing
TITLE="$1"
# Funkyness to read in our multi-line markdown as a variable to pass to GraphQL
read -r -d '' BODY << EOM
### Instructions
- Example instructions
- Bullet list
### Multi line markdown 🤯
p.s. You have to escape \`backticks\`
cc @your @team
EOM
gh api graphql -F title="$TITLE" -F body="$BODY" -f query='
mutation($title: String!, $body: String!) {
createDiscussion(input: {
repositoryId: "REPO_ID",
categoryId: "CATEGORY_ID",
title: $title,
body: $body
}) {
discussion { id }
}
}
'
# .github/workflows/weekly-standup.yml
name: Weekly Standup
on:
schedule:
- cron: 0 15 * * 5 # every Friday at 7 a.m. PST / 8 a.m. PDT
workflow_dispatch: # allow for manual trigger
jobs:
weekly_standup:
name: Weekly Standup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Generate the issue title with the current week dates
# ie "Weekly Team Standup - July 12-16"
- name: Generate issue title
id: title
run: echo "::set-output name=title::Weekly Team Standup - $(date --date 'last Monday' +'%B %d')-$(date +'%d')"
# Create new discussion
- run: script/weekly-standup.sh "${{ steps.title.outputs.title }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment