-
-
Notifications
You must be signed in to change notification settings - Fork 57
101 lines (87 loc) · 2.95 KB
/
Copy pathpostmortem-update.yml
File metadata and controls
101 lines (87 loc) · 2.95 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Postmortem Update
on:
push:
branches: [main]
workflow_dispatch:
inputs:
commit:
description: 'Specific commit hash to process'
required: false
force:
description: 'Force generation even if not a fix commit'
type: boolean
default: false
permissions:
contents: write
jobs:
update-postmortems:
runs-on: ubuntu-latest
# Only run for fix commits or manual trigger
if: |
github.event_name == 'workflow_dispatch' ||
startsWith(github.event.head_commit.message, 'fix')
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 10
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install pyyaml
# Install project dependencies for LLM (optional)
if [ -f requirements.txt ]; then
pip install openai tiktoken tenacity || true
fi
- name: Determine commit to process
id: commit
run: |
if [ -n "${{ github.event.inputs.commit }}" ]; then
echo "sha=${{ github.event.inputs.commit }}" >> $GITHUB_OUTPUT
else
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
- name: Generate postmortem
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_API_BASE: ${{ secrets.LLM_API_BASE }}
LLM_MODEL: ${{ secrets.LLM_MODEL }}
run: |
COMMIT="${{ steps.commit.outputs.sha }}"
FORCE_FLAG=""
if [ "${{ github.event.inputs.force }}" = "true" ]; then
FORCE_FLAG="--force"
fi
# Check if LLM is configured
if [ -z "$LLM_API_KEY" ]; then
echo "LLM_API_KEY not configured, using rule-based extraction"
NO_LLM="--no-llm"
else
NO_LLM=""
fi
# Run generation
python tools/postmortem_generate.py \
--commit "$COMMIT" \
--output postmortem/ \
$FORCE_FLAG \
$NO_LLM || echo "Generation skipped or failed"
- name: Check for changes
id: changes
run: |
if [ -n "$(git status --porcelain postmortem/)" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit postmortem updates
if: steps.changes.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add postmortem/
git commit -m "docs(postmortem): auto-generated from ${{ steps.commit.outputs.sha }}"
git push