File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ FILE=" ${1:- src/ glean/ __init__.py} "
5+
6+ # If the lines are already present, exit without modifying.
7+ if grep -Fq " extend_path(__path__, __name__)" " $FILE " ; then
8+ if [[ -n " ${OUTPUT:- } " ]]; then
9+ echo " patched=false" >> " $OUTPUT "
10+ fi
11+ exit 0
12+ fi
13+
14+ # Insert the two lines immediately after the first line.
15+ awk ' NR==1 {print $0; print "from pkgutil import extend_path\n"; print "__path__ = extend_path(__path__, __name__)\n"; next} 1' " $FILE " > " $FILE .new"
16+ mv " $FILE .new" " $FILE "
17+
18+ if [[ -n " ${OUTPUT:- } " ]]; then
19+ echo " patched=true" >> " $OUTPUT "
20+ fi
Original file line number Diff line number Diff line change 1+ name : Patch Speakeasy PR
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize]
6+ paths :
7+ - ' src/glean/__init__.py'
8+
9+ jobs :
10+ add-extend-path :
11+ if : contains(github.event.pull_request.title, 'Update SDK - Generate')
12+ runs-on : ubuntu-latest
13+ permissions :
14+ contents : write
15+ pull-requests : write
16+
17+ steps :
18+ - uses : actions/checkout@v4
19+ with :
20+ ref : ${{ github.head_ref }}
21+ fetch-depth : 0
22+
23+ - name : Patch glean/__init__.py with extend_path
24+ id : patch
25+ run : |
26+ OUTPUT=$GITHUB_OUTPUT .github/scripts/patch_extend_path.sh
27+
28+ - name : Commit and push if file changed
29+ if : steps.patch.outputs.patched == 'true'
30+ run : |
31+ git config --global user.name "github-actions[bot]"
32+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
33+
34+ git add src/glean/__init__.py
35+ git commit -m "ci: ensure extend_path lines in glean/__init__.py" || echo "No changes to commit"
36+ git push origin HEAD:${{ github.head_ref }}
You can’t perform that action at this time.
0 commit comments