Skip to content

Create PR for meeting notes #10

Create PR for meeting notes

Create PR for meeting notes #10

Workflow file for this run

name: Create PR for meeting notes
on:
workflow_dispatch:
inputs:
date:
description: |
Date of the meeting notes. MUST be understood by `date --date`.
Common examples are "now", "tomorrow", "next Wednesday", "2023-03-01"...
See https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html for full details.
required: false
default: "now"
type: string
schedule:
# this is every wednesday, but we want every two! check 'pre-create' job below
- cron: "00 12 * * WED"
pull_request:
types:
- labeled
permissions:
contents: write
pull-requests: write
# You need to enable 'Allow GitHub Actions to create and approve pull requests'
# in your Actions Settings too
jobs:
pre-create:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
outputs:
should-run: ${{ steps.return-value.outputs.should-run }}
date: ${{ steps.return-value.outputs.date }}
steps:
- name: Setup Python
if: github.event_name == 'schedule'
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dateutil
if: github.event_name == 'schedule'
run: python -m pip install python-dateutil
- name: Check if we need to run this week
if: github.event_name == 'schedule'
id: check-wednesday
shell: python
run: |
import os
from datetime import datetime
from dateutil.rrule import rrule, WEEKLY, WE
today = datetime.today()
print("Today is", today)
every_two_wednesdays = rrule(WEEKLY, interval=2, dtstart=datetime(2023, 3, 15), wkst=WE)
for wednesday in every_two_wednesdays:
print("Testing if today matches...", wednesday)
if wednesday.date() == today.date():
print("Match! Job should run.")
with open(os.environ['GITHUB_ENV'], 'a') as f:
print("should_run=yes", f)
elif wednesday > today:
print("Didn't match. Aborting.")
break
- name: Set output
id: return-value
run: |
set -x
if [[ ${{ github.event_name }} == workflow_dispatch ]]; then
echo "should-run=yes" >> $GITHUB_OUTPUT
echo "date=${{ github.event.inputs.date }}" >> $GITHUB_OUTPUT
elif [[ $should_run == yes ]]; then
echo "should-run=yes" >> $GITHUB_OUTPUT
# We can change this below to post notes some days in advance
echo "date=now" >> $GITHUB_OUTPUT
ellse
echo "should-run=no" >> $GITHUB_OUTPUT
echo "date=never" >> $GITHUB_OUTPUT
fi
create:
needs: [pre-create]
if: needs.pre-create.outputs.should-run == 'yes'
uses: Quansight-Labs/hackmd-meeting-notes-action/.github/workflows/create-meeting-notes-pr.yml@main
with:
date: ${{ needs.pre-create.outputs.date }}
template_path: meetings/agenda_template.md
output_path: meetings/archive/%Y%m%d_agenda_and_minutes.md
hackmd_team: conda-community
force_push: true
pr_body: |
New meeting notes available at ${env.hackmd_doc_url}.
Once done with the meeting, sync the note back to the repository by adding the `sync-hackmd-notes` label.
secrets:
HACKMD_TOKEN: ${{ secrets.HACKMD_TOKEN }}
sync:
if: github.event.label.name == 'sync-hackmd-notes'
uses: Quansight-Labs/hackmd-meeting-notes-action/.github/workflows/sync-meeting-notes-pr.yml@main
with:
pr_number: ${{ github.event.number }}
secrets:
HACKMD_TOKEN: ${{ secrets.HACKMD_TOKEN }}