11name : Generate Bindings
22on :
33 workflow_dispatch :
4- push :
5- branches : [main]
6- paths :
7- - .github/workflows/generate_bindings.yml
8- - gen/**
94 pull_request :
105 branches : [main]
116 paths :
127 - .github/workflows/generate_bindings.yml
13- - gen/**
8+ - gen/Project.toml
9+
1410concurrency :
1511 group : ${{ github.workflow }}-${{ github.ref || github.run_id }}
1612 cancel-in-progress : true
13+
14+ permissions :
15+ contents : write
16+
1717jobs :
1818 generate-bindings :
1919 name : Generate bindings
2020 runs-on : ubuntu-22.04
2121 timeout-minutes : 20
2222 steps :
23- - uses : actions/checkout@v4
23+ - name : Checkout PR branch
24+ uses : actions/checkout@v4
25+ with :
26+ ref : ${{ github.head_ref }}
27+ token : ${{ secrets.GITHUB_TOKEN }}
2428
2529 - uses : julia-actions/setup-julia@v1
2630 with :
2731 version : " 1.10.2"
2832
33+ - uses : julia-actions/cache@v2
34+
2935 - name : Run the generator
3036 run : ./gen/generate.sh
3137
32- - name : Create Pull Request (on push)
33- if : ${{ github.event_name == 'push' }}
34- uses : peter-evans/create-pull-request@v6
35- with :
36- commit-message : " Regenerate bindings"
37- title : " Regenerate bindings"
38- reviewers : |
39- quinnj
40- Octogonapus
41-
42- - name : Create Pull Request (on PR)
43- if : ${{ github.event_name == 'pull_request' }}
44- uses : peter-evans/create-pull-request@v6
45- with :
46- base : ${{ github.head_ref }}
47- commit-message : " Regenerate bindings"
48- title : " Regenerate bindings"
49- reviewers : |
50- quinnj
51- Octogonapus
38+ - name : Check for changes
39+ id : check_diff
40+ run : |
41+ if git diff --quiet; then
42+ echo "No changes detected."
43+ echo "changed=false" >> $GITHUB_ENV
44+ else
45+ echo "Changes detected."
46+ echo "changed=true" >> $GITHUB_ENV
47+ fi
48+
49+ - name : Commit and Push Changes
50+ if : env.changed == 'true'
51+ run : |
52+ git config --global user.name "github-actions[bot]"
53+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
54+ git add .
55+ git commit -m "Regenerate bindings"
56+ git push origin ${{ github.head_ref }}
0 commit comments