fix: fix secrets reference in Slack step (use env instead of secrets in if condition)

This commit is contained in:
Alexa Amundson
2026-03-14 14:07:46 -05:00
parent 08e9a9ae8f
commit 5f171c5f2a

View File

@@ -2,7 +2,7 @@ name: Daily KPI Collection
on: on:
schedule: schedule:
- cron: '0 6 * * *' # 6 AM UTC = midnight CST - cron: '0 6 * * *'
workflow_dispatch: workflow_dispatch:
permissions: permissions:
@@ -19,13 +19,6 @@ jobs:
with: with:
python-version: '3.11' python-version: '3.11'
- name: Install GitHub CLI
run: |
type -p curl >/dev/null || sudo apt-get install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update && sudo apt-get install gh -y
- name: Collect GitHub KPIs - name: Collect GitHub KPIs
env: env:
GH_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }}
@@ -33,10 +26,11 @@ jobs:
- name: Generate daily aggregate - name: Generate daily aggregate
run: | run: |
source lib/common.sh TODAY=$(date +%Y-%m-%d)
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
python3 -c " python3 -c "
import json, glob, os import json, glob, os
today = '$(date +%Y-%m-%d)' today = '$TODAY'
data_dir = 'data' data_dir = 'data'
os.makedirs(f'{data_dir}/daily', exist_ok=True) os.makedirs(f'{data_dir}/daily', exist_ok=True)
snapshots = {} snapshots = {}
@@ -47,7 +41,7 @@ jobs:
gh = snapshots.get('github', {}) gh = snapshots.get('github', {})
daily = { daily = {
'date': today, 'date': today,
'collected_at': '$(date -u +%Y-%m-%dT%H:%M:%SZ)', 'collected_at': '$NOW',
'summary': { 'summary': {
'commits_today': gh.get('commits', {}).get('today', 0), 'commits_today': gh.get('commits', {}).get('today', 0),
'prs_open': gh.get('pull_requests', {}).get('open', 0), 'prs_open': gh.get('pull_requests', {}).get('open', 0),
@@ -71,9 +65,9 @@ jobs:
run: bash reports/markdown-report.sh run: bash reports/markdown-report.sh
- name: Post to Slack - name: Post to Slack
if: ${{ secrets.SLACK_WEBHOOK_URL != '' }}
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: env.SLACK_WEBHOOK_URL != ''
run: bash reports/slack-notify.sh run: bash reports/slack-notify.sh
- name: Commit data - name: Commit data