Skip to content

Commit 64f858b

Browse files
committed
Open a PR if there are changes
1 parent d9485cf commit 64f858b

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

.github/workflows/sync-test-fixtures.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- "spike/pull-fixtures"
7+
workflow_dispatch:
78

89
jobs:
910
sync_fixtures:
@@ -17,6 +18,7 @@ jobs:
1718
with:
1819
ruby-version: '3.4'
1920
bundler-cache: true
21+
- uses: actions/setup-gh@v4
2022
- name: Sync fixtures
2123
run: |
2224
TMP_DIR=$(mktemp -d)
@@ -28,27 +30,31 @@ jobs:
2830
ls -al spec/fixtures.http/
2931
rsync -a --delete "$TMP_DIR/dnsimple-developer-main/fixtures/v2/api/" spec/fixtures.http/
3032
ls -al spec/fixtures.http/
31-
- name: Run tests
32-
run: bundle exec rake
33-
- name: Commit synced fixtures
33+
- name: Create a PR to sync fixtures if there are changes
3434
run: |
3535
# Configure Git identity for the workflow
3636
git config --global user.name "github-actions"
3737
git config --global user.email "github-actions@github.com"
3838
3939
# Create and switch to a new branch
4040
BRANCH="chore/sync-fixtures-${GITHUB_RUN_ID}"
41+
NOW="$(date +'%Y-%m-%d %H:%M:%S')""
4142
git checkout -b "$BRANCH"
4243
4344
# Stage changes
4445
git add spec/fixtures.http
4546
4647
# Commit if there are staged changes
4748
if ! git diff --cached --quiet; then
48-
git commit -m "chore: sync test fixtures"
49+
git commit -m "chore: sync test fixtures as of $NOW"
4950
git push -u origin "$BRANCH"
51+
gh pr create \
52+
--title "chore: Sync fixtures as of $NOW" \
53+
--body "This PR replaces the fixtures in this repository with those from https://github.com/dnsimple/dnsimple-developer" \
54+
--base main \
55+
--head "$BRANCH"
5056
else
51-
echo "No fixture changes to commit."
57+
echo "No fixture detected; nothing to do"
5258
fi
5359
env:
5460
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)