-
Notifications
You must be signed in to change notification settings - Fork 329
82 lines (80 loc) · 2.56 KB
/
Copy pathspec_update.yml
File metadata and controls
82 lines (80 loc) · 2.56 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
name: Spec Update
on:
workflow_dispatch:
repository_dispatch:
types: [spec_update]
permissions: # least privilege; PR creation uses the SPEC_UPDATE_TOKEN PAT
contents: read
jobs:
Update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Python environment
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY_MM_DD
utcOffset: "-08:00"
- name: Update Modules
run: |
git submodule init
git submodule update --remote --recursive
- name: Generate Branch Name
id: git-branch
env:
FORMATTED_TIME: ${{ steps.current-time.outputs.formattedTime }}
run: |
echo "branch=spec_update_${FORMATTED_TIME}" >> "$GITHUB_OUTPUT"
- name: Generate Num Diffs
id: git-diff-num
run: |
diffs=$(git diff --submodule spec | grep ">" | wc -l)
echo "Number of Spec diffs: $diffs"
echo "num-diff=$diffs" >> "$GITHUB_OUTPUT"
- name: Generate Diff
id: git-diff
env:
NUM_DIFF: ${{ steps.git-diff-num.outputs.num-diff }}
run: |
cd spec
gitdiff=$(git log -n "$NUM_DIFF" --pretty="format:%n %H %n%n %b")
commit="Automated Spec Update $gitdiff"
while true; do
delimiter="SPEC_UPDATE_EOF_$(python -c 'import uuid; print(uuid.uuid4())')"
if ! grep -Fxq "$delimiter" <<< "$commit"; then
break
fi
done
{
printf 'commit<<%s\n' "$delimiter"
printf '%s\n' "$commit"
printf '%s\n' "$delimiter"
} >> "$GITHUB_OUTPUT"
cd ..
- name: Generate New Routes
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python generate_base_client.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
if: steps.git-diff-num.outputs.num-diff != 0
with:
token: ${{ secrets.SPEC_UPDATE_TOKEN }}
commit-message: |
${{ steps.git-diff.outputs.commit}}
branch: ${{ steps.git-branch.outputs.branch }}
delete-branch: true
title: 'Automated Spec Update'
body: |
${{ steps.git-diff.outputs.commit}}
base: 'main'
team-reviewers: |
owners
maintainers
draft: false