Skip to content

Commit

Permalink
ci: workflow to update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
chintankavathia committed Nov 26, 2024
1 parent 857218c commit 3e33a96
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions .github/workflows/update_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,38 @@ jobs:
cd snapshot-repo
git config user.name "GitHub Actions"
git config user.email "[email protected]"
# Automatically generate branch name
# Ensure remote is set up correctly
git remote set-url origin https://${SNAPSHOT_REPO_TOKEN}@github.com/chintankavathia/ngx-datatable-snapshots.git
# Fetch remote branches to avoid the "no upstream branch" error
git fetch origin
BRANCH_NAME="snapshot-update-${{ github.run_id }}"
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
- name: Copy generated snapshots
run: |
rsync -av --delete playwright/snapshots/ snapshot-repo/
rsync -av --delete playwright/snapshots/ snapshot-repo/snapshots
- name: Commit and push changes
- name: Commit and push changes to snapshot repo
working-directory: snapshot-repo
run: |
git add .
# Automatically generate commit message
COMMIT_MESSAGE="Update Playwright snapshots (Run ID: ${{ github.run_id }})"
git commit -m "$COMMIT_MESSAGE"
git commit -m "$COMMIT_MESSAGE" || echo "No changes to commit"
# Ensure remote is set up correctly
git remote set-url origin https://${{ secrets.SNAPSHOT_REPO_TOKEN }}@github.com/chintankavathia/ngx-datatable-snapshots.git
git push origin $BRANCH_NAME
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.SNAPSHOT_REPO_TOKEN }}
repository: chintankavathia/ngx-datatable-snapshots.git
base: main
head: $BRANCH_NAME
# Automatically generate title and body
title: 'Update Playwright Snapshots (Run ID: ${{ github.run_id }})'
body: |
This PR updates the Playwright snapshots generated by workflow run ID: ${{ github.run_id }}.
- Base branch: ${{ github.ref_name }}
- Commit: ${{ github.sha }}
- name: Create a pull request
run: |
git remote set-url origin https://${{ secrets.SNAPSHOT_REPO_TOKEN }}@github.com/chintankavathia/ngx-datatable-snapshots.git
# Store the PAT in a file that can be accessed by the
# GitHub CLI.
echo "${{ secrets.SNAPSHOT_REPO_TOKEN }}" > token.txt
gh auth login --with-token < token.txt
gh pr create --base main --head snapshot-update-${{ github.run_id }} --title "Update Playwright snapshots" --body "Automated PR to update snapshots based on run ID ${{ github.run_id }}."

0 comments on commit 3e33a96

Please sign in to comment.