Skip to content

test committing changed files to a branch #6

test committing changed files to a branch

test committing changed files to a branch #6

name: Sync test fixtures
on:
push:
branches:
- "spike/pull-fixtures"
jobs:
sync_fixtures:
name: Sync test fixtures
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Sync fixtures
run: |
TMP_DIR=$(mktemp -d)
curl -fsSL "https://codeload.github.com/dnsimple/dnsimple-developer/tar.gz/refs/heads/main" \
| tar -xz -C "$TMP_DIR"
pwd
ls -al $TMP_DIR
ls -al "$TMP_DIR/dnsimple-developer-main/"
ls -al spec/fixtures.http/
rsync -a --delete "$TMP_DIR/dnsimple-developer-main/fixtures/v2/api" spec/fixtures.http/
ls -al spec/fixtures.http/
- name: Run tests
run: bundle exec rake
- name: Commit synced fixtures
run: |
# Configure Git identity for the workflow
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
# Create and switch to a new branch
BRANCH="chore/sync-fixtures-${GITHUB_RUN_ID}"
git checkout -b "$BRANCH"
# Stage changes
git add spec/fixtures.http
# Commit if there are staged changes
if ! git diff --cached --quiet; then
git commit -m "chore: sync test fixtures"
git push -u origin "$BRANCH"
else
echo "No fixture changes to commit."
fi
env:
GITHUB_TOKEN: ${{ github.token }}