Skip to content

Commit f3e6572

Browse files
committed
Add manual full examples rebuild workflow
1 parent 2c271bd commit f3e6572

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

.github/workflows/trigger-site-rebuild.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: Trigger site rebuild
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
full_rebuild:
7+
description: 'Validate, build, archive, and publish all examples'
8+
required: false
9+
default: true
10+
type: boolean
411
push:
512
branches:
613
- 'master'
@@ -16,20 +23,25 @@ on:
1623
jobs:
1724
validate:
1825
runs-on: ubuntu-latest
19-
if: "!contains(github.event.head_commit.message, 'skip-ci')"
26+
if: "github.event_name != 'push' || !contains(github.event.head_commit.message, 'skip-ci')"
2027
steps: [
2128
{ name: 'Checkout', uses: actions/checkout@v4, with: { fetch-depth: 0 } },
2229
{ name: 'Install Python', uses: actions/setup-python@v4, with: { python-version: 3.10.5, architecture: x64 } },
2330
{
2431
name: 'Validate examples',
25-
run: 'python validate_examples.py --changed-from "${{ github.event.before }}" --changed-to "${{ github.sha }}"'
32+
env: {
33+
BEFORE_SHA: '${{ github.event.before }}',
34+
AFTER_SHA: '${{ github.sha }}',
35+
FULL_REBUILD: '${{ github.event_name == ''workflow_dispatch'' && inputs.full_rebuild }}'
36+
},
37+
run: 'if [ "$FULL_REBUILD" = "true" ]; then python validate_examples.py; else python validate_examples.py --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA"; fi'
2638
}
2739
]
2840

2941
build:
3042
runs-on: ubuntu-latest
3143
needs: validate
32-
if: "!contains(github.event.head_commit.message, 'skip-ci')"
44+
if: "github.event_name != 'push' || !contains(github.event.head_commit.message, 'skip-ci')"
3345
outputs:
3446
example_count: ${{ steps.count.outputs.example_count }}
3547
changed_examples: ${{ steps.count.outputs.changed_examples }}
@@ -50,21 +62,27 @@ jobs:
5062
name: 'Count touched examples',
5163
env: {
5264
BEFORE_SHA: '${{ github.event.before }}',
53-
AFTER_SHA: '${{ github.sha }}'
65+
AFTER_SHA: '${{ github.sha }}',
66+
FULL_REBUILD: '${{ github.event_name == ''workflow_dispatch'' && inputs.full_rebuild }}'
5467
},
55-
run: 'echo "example_count=$(python build_examples.py --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA" --dry-run)" >> "$GITHUB_OUTPUT"; echo "changed_examples=$(python build_examples.py --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA" --list-json)" >> "$GITHUB_OUTPUT"'
68+
run: 'if [ "$FULL_REBUILD" = "true" ]; then echo "example_count=$(python build_examples.py --dry-run)" >> "$GITHUB_OUTPUT"; echo "changed_examples=$(python build_examples.py --list-json)" >> "$GITHUB_OUTPUT"; else echo "example_count=$(python build_examples.py --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA" --dry-run)" >> "$GITHUB_OUTPUT"; echo "changed_examples=$(python build_examples.py --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA" --list-json)" >> "$GITHUB_OUTPUT"; fi'
5669
},
5770
{
5871
name: 'Build touched examples',
5972
if: steps.count.outputs.example_count != '0',
60-
run: 'python build_examples.py --bob-jar bob.jar --changed-from "${{ github.event.before }}" --changed-to "${{ github.sha }}"'
73+
env: {
74+
BEFORE_SHA: '${{ github.event.before }}',
75+
AFTER_SHA: '${{ github.sha }}',
76+
FULL_REBUILD: '${{ github.event_name == ''workflow_dispatch'' && inputs.full_rebuild }}'
77+
},
78+
run: 'if [ "$FULL_REBUILD" = "true" ]; then python build_examples.py --bob-jar bob.jar; else python build_examples.py --bob-jar bob.jar --changed-from "$BEFORE_SHA" --changed-to "$AFTER_SHA"; fi'
6179
}
6280
]
6381

6482
publish:
6583
runs-on: ubuntu-latest
6684
needs: build
67-
if: needs.build.outputs.example_count != '0' && !contains(github.event.head_commit.message, 'skip-ci')
85+
if: "needs.build.outputs.example_count != '0' && (github.event_name != 'push' || !contains(github.event.head_commit.message, 'skip-ci'))"
6886
steps: [
6987
{ name: 'Checkout', uses: actions/checkout@v4, with: { fetch-depth: 1 } },
7088
{ name: 'Install Python', uses: actions/setup-python@v4, with: { python-version: 3.10.5, architecture: x64 } },

0 commit comments

Comments
 (0)