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