Skip to content

Commit b00e8bc

Browse files
committed
fix(docs): more applicable example
1 parent 342441f commit b00e8bc

2 files changed

Lines changed: 62 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,68 @@ concurrency:
2020
cancel-in-progress: false
2121

2222
jobs:
23+
# This job finds the SHA of the last successful deployment
24+
find_last_deployment:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
last_sha: ${{ steps.get_sha.outputs.sha }}
28+
steps:
29+
- name: Get last deployment SHA
30+
id: get_sha
31+
run: |
32+
# Install GitHub CLI if not available
33+
if ! command -v gh &> /dev/null; then
34+
echo "Installing GitHub CLI..."
35+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
36+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
37+
sudo apt update
38+
sudo apt install gh
39+
fi
40+
41+
# Authenticate with GitHub token
42+
echo "${{ github.token }}" | gh auth login --with-token
43+
44+
# Get the last successful deployment workflow run
45+
WORKFLOW_ID=$(gh api /repos/${{ github.repository }}/actions/workflows/deploy.yml | jq -r '.id')
46+
47+
# Find the last successful run of the deploy workflow
48+
LAST_SHA=$(gh api "/repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs?status=success&per_page=1" | jq -r '.workflow_runs[0].head_sha')
49+
50+
# If no previous successful run, use a fallback
51+
if [ "$LAST_SHA" = "null" ] || [ -z "$LAST_SHA" ]; then
52+
echo "No previous successful deployment found. Using current SHA as reference."
53+
LAST_SHA="${{ github.sha }}"
54+
fi
55+
56+
echo "Last successful deployment SHA: $LAST_SHA"
57+
echo "sha=$LAST_SHA" >> $GITHUB_OUTPUT
58+
2359
check_changes:
2460
runs-on: ubuntu-latest
61+
needs: find_last_deployment
2562
outputs:
2663
should_build: ${{ steps.filter.outputs.should_build }}
2764
steps:
2865
- name: Checkout
2966
uses: actions/checkout@v4
3067
with:
31-
fetch-depth: 50
68+
fetch-depth: 0
3269

70+
# For workflow_dispatch events, we always want to build
71+
- name: Set manual trigger output
72+
if: github.event_name == 'workflow_dispatch'
73+
run: |
74+
echo "SHOULD_BUILD=true" >> $GITHUB_ENV
75+
76+
# Only run the filter if not manually triggered
3377
- name: Filter changes
78+
if: github.event_name != 'workflow_dispatch'
3479
uses: dorny/paths-filter@v3
3580
id: filter
3681
with:
82+
# Compare against the last successful deployment SHA
83+
base: ${{ needs.find_last_deployment.outputs.last_sha }}
84+
# Look for changes in these patterns
3785
filters: |
3886
should_build:
3987
- '.stories.tsx'
@@ -42,10 +90,20 @@ jobs:
4290
- 'package.json'
4391
- 'landing/package.json'
4492
93+
# Set the output for use by the build job
94+
- name: Set final output
95+
id: set_output
96+
run: |
97+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
98+
echo "should_build=true" >> $GITHUB_OUTPUT
99+
else
100+
echo "should_build=${{ steps.filter.outputs.should_build || 'false' }}" >> $GITHUB_OUTPUT
101+
fi
102+
45103
build:
46104
runs-on: ubuntu-latest
47105
needs: check_changes
48-
if: needs.check_changes.outputs.should_build == 'true' || github.event_name == 'workflow_dispatch'
106+
if: needs.check_changes.outputs.should_build == 'true'
49107
steps:
50108
- name: Checkout
51109
uses: actions/checkout@v4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ A smart, headless time range picker that speaks human.
4141
import { TimeSlice } from '@bizarre/ui'
4242

4343
function MyComponent() {
44-
const handleChange = (range) => {
44+
const handleConfirm = (range) => {
4545
console.log('Selected range:', range)
4646
}
4747

4848
return (
49-
<TimeSlice.Root onDateRangeChange={handleChange}>
49+
<TimeSlice.Root onDateRangeConfirm={handleConfirm}>
5050
<TimeSlice.Input />
5151
<TimeSlice.Portal>
5252
<TimeSlice.Shortcut duration={{ minutes: 15 }}>

0 commit comments

Comments
 (0)