Skip to content

Commit c977f3b

Browse files
committed
Only commit and open PR if there are new meetups
1 parent 718420b commit c977f3b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/meetups.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,23 @@ jobs:
2626
- name: Verify Meetups Data
2727
run: bundle exec rake verify_meetups
2828

29-
- name: Set up the formatted date and branch name
29+
- name: Set up the formatted date, branch name and PR title
3030
run: |
3131
echo "FORMATTED_DATE=$(date +'%B %d, %Y')" >> $GITHUB_ENV
3232
echo "BRANCH_TO_MERGE=new-meetups-$(date +'%Y-%m-%d')" >> $GITHUB_ENV
3333
echo "PULL_REQUEST_TITLE=$(cat ./pull_request_title.txt)" >> $GITHUB_ENV
3434
35+
- name: Check if there are any new meetups
36+
run: |
37+
if [[ -n $(git diff --name-only _data/meetups.yml) ]]; then
38+
echo "NEW_MEETUPS=true" >> $GITHUB_ENV
39+
else
40+
echo "NEW_MEETUPS=false" >> $GITHUB_ENV
41+
fi
42+
3543
- name: Commit New Meetups
3644
uses: stefanzweifel/git-auto-commit-action@v5
45+
if: ${{ env.NEW_MEETUPS == 'true' }}
3746
with:
3847
# Optional. Commit message for the created commit.
3948
# Defaults to "Apply automatic changes"
@@ -97,6 +106,7 @@ jobs:
97106
create_branch: true
98107

99108
- name: Create Pull Request
109+
if: ${{ env.NEW_MEETUPS == 'true' }}
100110
run: gh pr create -B main -H ${{ env.BRANCH_TO_MERGE }} --title "${{ env.PULL_REQUEST_TITLE }}" --body-file "./new_meetups.md"
101111
env:
102112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)