Skip to content

Commit d8f0417

Browse files
chore: Publish nightly only when there were changes on branch (#8657)
## Summary This PR now checks commits in the last 24hours, and only then it run the nightly publish - I've tested it locally and it appeared to correctly set the variables and work. ## Test plan
1 parent 699c1c2 commit d8f0417

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check branch changes
2+
on:
3+
workflow_call:
4+
inputs:
5+
branch:
6+
required: true
7+
type: string
8+
outputs:
9+
has_changes:
10+
value: ${{ jobs.check.outputs.has_changes }}
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
has_changes: ${{ steps.commit_check.outputs.has_changes }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
ref: ${{ inputs.branch }}
23+
24+
- id: commit_check
25+
run: |
26+
COUNT=$(git log --oneline --since='24 hours ago' | wc -l)
27+
echo "Found $COUNT commits in the last 24 hours on branch ${{ inputs.branch }}"
28+
29+
if [ "$COUNT" -gt 0 ]; then
30+
echo "has_changes=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "has_changes=false" >> $GITHUB_OUTPUT
33+
fi

.github/workflows/npm-reanimated-publish-nightly.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,34 @@ permissions:
1111
id-token: write # For publishing on NPM using OIDC
1212

1313
jobs:
14-
npm-reanimated-4-publish-nightly:
14+
check-v4-changes:
1515
if: github.repository == 'software-mansion/react-native-reanimated'
16+
uses: ./.github/workflows/check-branch-changes.yml
17+
with:
18+
branch: main
19+
20+
npm-reanimated-4-publish-nightly:
21+
needs: check-v4-changes
22+
if: |
23+
github.repository == 'software-mansion/react-native-reanimated' &&
24+
needs.check-v4-changes.outputs.has_changes == 'true'
1625
uses: ./.github/workflows/npm-reanimated-package-build.yml
1726
with:
1827
option: --nightly
1928
publish_on_npm: true
2029

21-
npm-reanimated-3-publish-nightly:
30+
check-v3-changes:
2231
if: github.repository == 'software-mansion/react-native-reanimated'
32+
uses: ./.github/workflows/check-branch-changes.yml
33+
with:
34+
# Remember to update the branch on new minor releases.
35+
branch: 3.19-stable
36+
37+
npm-reanimated-3-publish-nightly:
38+
needs: check-v3-changes
39+
if: |
40+
github.repository == 'software-mansion/react-native-reanimated' &&
41+
needs.check-v3-changes.outputs.has_changes == 'true'
2342
uses: ./.github/workflows/npm-reanimated-package-build.yml
2443
with:
2544
option: --nightly

0 commit comments

Comments
 (0)