Skip to content

Commit 40f977c

Browse files
authored
Create sync-test-fixtures.yml
1 parent ee7d6df commit 40f977c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Sync test fixtures
3+
4+
on:
5+
push:
6+
branches:
7+
- "add-fixtures-sync-workflow"
8+
workflow_dispatch:
9+
10+
jobs:
11+
sync_fixtures:
12+
name: Sync test fixtures
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
- name: Sync fixtures
18+
run: |
19+
TMP_DIR=$(mktemp -d)
20+
curl -fsSL "https://codeload.github.com/dnsimple/dnsimple-developer/tar.gz/refs/heads/main" \
21+
| tar -xz -C "$TMP_DIR"
22+
rsync -a --delete "$TMP_DIR/dnsimple-developer-main/fixtures/v2/" tests/fixtures/v2/
23+
- name: Create a PR to sync fixtures if there are changes
24+
run: |
25+
cat <<'MD' > pr_body.md
26+
This PR replaces the fixtures in this repository with those from https://github.com/dnsimple/dnsimple-developer/
27+
28+
## Checklist
29+
- [ ] Close and re-open this PR to trigger the CI workflow (it does not run automatically)
30+
- [ ] Ensure the CI workflow passes before merging
31+
MD
32+
33+
# Configure Git identity for the workflow
34+
git config --global user.name "github-actions"
35+
git config --global user.email "[email protected]"
36+
37+
# Create and switch to a new branch
38+
BRANCH="chore/sync-fixtures-${GITHUB_RUN_ID}"
39+
NOW="$(date +'%Y-%m-%d %H:%M:%S')"
40+
git checkout -b "$BRANCH"
41+
42+
# Stage changes
43+
git add tests/fixtures/v2
44+
45+
# Commit if there are staged changes
46+
if ! git diff --cached --quiet; then
47+
git commit -m "chore: sync test fixtures as of $NOW"
48+
git push -u origin "$BRANCH"
49+
50+
gh pr create \
51+
--title "chore: Sync fixtures as of $NOW" \
52+
--body-file pr_body.md \
53+
--base main \
54+
--head "$BRANCH"
55+
else
56+
echo "No fixture detected; nothing to do"
57+
fi
58+
env:
59+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)