Skip to content

Commit

Permalink
CI Pipeline: create cassettes in fork (Significant-Gravitas#4257)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicholas Tindle <[email protected]>
  • Loading branch information
2 people authored and ppetermann committed May 22, 2023
1 parent 67bb5e3 commit 5bbc3e0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 54 deletions.
49 changes: 0 additions & 49 deletions .github/workflows/add-cassettes.yml

This file was deleted.

38 changes: 33 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,42 @@ jobs:
uses: codecov/codecov-action@v3

- name: Stage new files and commit
id: stage_files
run: |
COMMIT_SHA=$(git rev-parse HEAD) # take the sha before committing the cassette
git add tests
git diff --cached --quiet && echo "No changes to commit" && exit 0
git config user.email "[email protected]"
git config user.name "GitHub Actions"
git commit -m "Add new cassettes"
git checkout -b cassette-diff-${COMMIT_SHA}
git remote add target https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.event.pull_request.base.repo.full_name }}
git push -f target cassette-diff-${COMMIT_SHA}
TIMESTAMP_COMMIT=$(date +%Y%m%d%H%M%S) # generate a timestamp
echo "TIMESTAMP_COMMIT=TIMESTAMP_COMMIT" >> $GITHUB_ENV

- name: Create PR
id: create_pr
if: ${{ env.TIMESTAMP_COMMIT != null }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update cassettes
branch: cassette-diff-PR-${{ github.event.pull_request.number }}-${{ env.TIMESTAMP_COMMIT }}
title: "Update cassette-diff-PR${{ github.event.pull_request.number }}-${{ env.TIMESTAMP_COMMIT }}"
body: "This PR updates the cassettes. Please merge it."


- name: Check PR
if: ${{ env.TIMESTAMP_COMMIT != null }}
run: |
echo "Pull Request Number - ${{ steps.create_pr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create_pr.outputs.pull-request-url }}"
- name: Comment PR URL in the current PR
if: ${{ env.TIMESTAMP_COMMIT != null }}
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
Please click [HERE](${{ steps.create_pr.outputs.pull-request-url }}) and merge this PR to update the cassettes.
- name: Fail if new PR created
if: ${{ env.TIMESTAMP_COMMIT != null }}
run: exit 1

0 comments on commit 5bbc3e0

Please sign in to comment.