Skip to content

Commit d5b94af

Browse files
committed
Add fetch_and_log.yaml
1 parent 56eb31f commit d5b94af

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Fetch and Log Workflow Runs
2+
3+
on:
4+
# schedule:
5+
# - cron: "0 */1 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
fetch-workflows:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
workflow_ids: ${{ steps.fetch-ids.outputs.workflow_ids }}
13+
14+
steps:
15+
- name: Fetch Workflow IDs from Last X Hours
16+
id: fetch-ids
17+
run: |
18+
HOURS=1
19+
WORKFLOW_IDS=$(gh run list --repo $GITHUB_REPOSITORY --limit 100 --json databaseId,status,createdAt --jq '[.[] | select(.createdAt > (now - (1 * 3600))) | .databaseId] | @json')
20+
LAST_RUN_ID=$(echo $WORKFLOW_IDS | jq '.[-1]')
21+
22+
23+
echo "last_run_id=$LAST_RUN_ID" >> $GITHUB_ENV
24+
echo "workflow_ids=$WORKFLOW_IDS" >> $GITHUB_OUTPUT
25+
26+
gh secret set LAST_PROCESSED_RUN_ID --body $LAST_RUN_ID
27+
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
# - name: Save Last Processed Run ID
32+
# if: success()
33+
# run: |
34+
# gh secret set LAST_PROCESSED_RUN_ID --body "$last_run_id"
35+
36+
process-logs:
37+
needs: fetch-workflows
38+
runs-on: ubuntu-latest
39+
# strategy:
40+
# matrix:
41+
# run_id: ${{ fromJson(needs.fetch-workflows.outputs.workflow_ids || '[]') }}
42+
steps:
43+
# - run:
44+
# echo ${{ matrix.run_id }}
45+
- run: |
46+
echo "processing logs...."
47+
echo "-----------------"
48+
echo ${{ needs.fetch-workflows.outputs.workflow_ids }}
49+
echo "-----------------"
50+
echo ${{ fromJson(needs.fetch-workflows.outputs.workflow_ids || '[]') }}
51+
echo "-----------------"
52+
53+
# process-logs:
54+
# needs: fetch-workflows
55+
# runs-on: ubuntu-latest
56+
# strategy:
57+
# matrix:
58+
# run_id: ${{ fromJson(needs.fetch-workflows.outputs.workflow_ids) }}
59+
60+
# steps:
61+
# - name: Send Workflow Logs to Splunk
62+
# uses: ykoer/github-workflow-splunk-logger@dev
63+
# with:
64+
# github_token: ${{ secrets.GITHUB_TOKEN }}
65+
# splunk_url: ${{ vars.HEC_URL }}
66+
# splunk_token: ${{ secrets.HEC_TOKEN }}
67+
# run_id: ${{ matrix.run_id }}

0 commit comments

Comments
 (0)