-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 2.31 KB
/
collect-workflow-metrics.yml
File metadata and controls
70 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Collect Workflow Metrics
on:
schedule:
# Run every 10 minutes to catch completed workflow runs
- cron: '*/10 * * * *'
workflow_dispatch:
inputs:
lookback_hours:
description: 'Hours to look back for workflow runs'
required: false
default: '3'
type: string
jobs:
collect-workflow-metrics:
runs-on: ubuntu-latest
environment: main
steps:
- name: Check out code
uses: actions/checkout@v4
# Restore deduplication state from previous run
- name: Restore state cache
uses: actions/cache/restore@v4
with:
path: ./state
key: workflow-state-${{ github.run_id }}
restore-keys: |
workflow-state-
- name: Build and run Docker container
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTEL_EXPORTER_OTLP_ENDPOINT: ${{ secrets.OTEL_EXPORTER_OTLP_ENDPOINT }}
OTEL_EXPORTER_OTLP_HEADERS: ${{ secrets.OTEL_EXPORTER_OTLP_HEADERS }}
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
LOOKBACK_HOURS: ${{ inputs.lookback_hours || '3' }}
run: |
echo "OTEL_EXPORTER_OTLP_ENDPOINT is set: ${OTEL_EXPORTER_OTLP_ENDPOINT:+true}"
echo "WORKFLOW_LOOKBACK_HOURS: $LOOKBACK_HOURS"
docker build -t github-workflow-metrics -f Dockerfile.workflow .
docker run \
-e GITHUB_TOKEN="$GITHUB_TOKEN" \
-e OTEL_EXPORTER_OTLP_ENDPOINT="$OTEL_EXPORTER_OTLP_ENDPOINT" \
-e OTEL_EXPORTER_OTLP_HEADERS="$OTEL_EXPORTER_OTLP_HEADERS" \
-e OTEL_EXPORTER_OTLP_PROTOCOL="$OTEL_EXPORTER_OTLP_PROTOCOL" \
-e WORKFLOW_LOOKBACK_HOURS="$LOOKBACK_HOURS" \
-v "$(pwd)/state:/app/state" \
github-workflow-metrics
# Save state for next run (always run even if previous steps fail)
- name: Save state cache
if: always()
uses: actions/cache/save@v4
with:
path: ./state
key: workflow-state-${{ github.run_id }}
- name: Upload state as artifact (for debugging)
if: always()
uses: actions/upload-artifact@v4
with:
name: workflow-state
path: ./state/processed_workflow_runs.json
retention-days: 7
if-no-files-found: ignore