From 5bbd0989cc8b2741b3e3d2ed679d6c28b7e15a60 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 26 May 2026 19:36:53 +0000 Subject: [PATCH 1/2] chore(ci): rename monthly time reporting workflow --- .../workflows/{time-reporting.yml => monthly-time-reporting.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{time-reporting.yml => monthly-time-reporting.yml} (100%) diff --git a/.github/workflows/time-reporting.yml b/.github/workflows/monthly-time-reporting.yml similarity index 100% rename from .github/workflows/time-reporting.yml rename to .github/workflows/monthly-time-reporting.yml From 5d141d1b243dd7b5f2a3cc1ad4a198c54d42e401 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Wed, 27 May 2026 00:03:45 +0000 Subject: [PATCH 2/2] ci: workflow for bi-weekly time reporting --- .github/workflows/biweekly-time-reporting.yml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/biweekly-time-reporting.yml diff --git a/.github/workflows/biweekly-time-reporting.yml b/.github/workflows/biweekly-time-reporting.yml new file mode 100644 index 00000000..7c7b143f --- /dev/null +++ b/.github/workflows/biweekly-time-reporting.yml @@ -0,0 +1,86 @@ +name: Bi-Weekly Time Reporting +description: Posts a time report from Toggl to Slack of all billable time in the date range (defaults to prior 2 weeks). + +on: + workflow_dispatch: + inputs: + start-date: + description: "Start date for the report period (YYYY-MM-DD)" + required: false + end-date: + description: "End date for the report period (YYYY-MM-DD)" + required: false + +jobs: + time-reporting: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version-file: .github/workflows/.python-version + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + + - name: Download Toggl time entries + id: download + env: + TOGGL_API_TOKEN: "${{ secrets.TOGGL_API_TOKEN }}" + TOGGL_USER_AGENT: "compilerla/compiler-admin" + TOGGL_WORKSPACE_ID: "${{ secrets.TOGGL_WORKSPACE_ID }}" + run: | + START_DATE="${{ github.event.inputs.start-date }}" + END_DATE="${{ github.event.inputs.end-date }}" + + if [[ -z "$START_DATE" && -z "$END_DATE" ]]; then + END_DATE=$(date -d "yesterday" +%Y-%m-%d) + START_DATE=$(date -d "$END_DATE - 13 days" +%Y-%m-%d) + elif [[ -n "$START_DATE" && -z "$END_DATE" ]]; then + END_DATE=$(date -d "$START_DATE + 13 days" +%Y-%m-%d) + elif [[ -z "$START_DATE" && -n "$END_DATE" ]]; then + START_DATE=$(date -d "$END_DATE - 13 days" +%Y-%m-%d) + fi + + ARGS="--start=$START_DATE --end=$END_DATE" + + OUTPUT=$(compiler-admin time download $ARGS) + echo "$OUTPUT" + + FILENAME=$(echo "$OUTPUT" | grep "Download complete:" | cut -d' ' -f3) + echo "filename=$FILENAME" >> $GITHUB_OUTPUT + + - name: Summarize + id: summarize + run: | + FILENAME="${{ steps.download.outputs.filename }}" + { + echo "summary<> "$GITHUB_OUTPUT" + + - name: Post to Slack + id: slack + if: success() + uses: slackapi/slack-github-action@v3.0.1 + with: + method: files.uploadV2 + token: ${{ secrets.SLACK_BOT_TOKEN }} + payload: | + channel_id: ${{ secrets.SLACK_CHANNEL_ID }} + initial_comment: "${{ steps.summarize.outputs.summary }}" + file: ${{ steps.download.outputs.filename }} + filename: ${{ steps.download.outputs.filename }} + + - name: Cleanup + id: cleanup + if: always() + run: | + FILENAME="${{ steps.download.outputs.filename }}" + rm -f "$FILENAME"