update-snapshot #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update-snapshot | |
on: | |
workflow_run: | |
workflows: [build] | |
types: [completed] | |
branches: [github-actions/upgrade-main] | |
jobs: | |
on-failure: | |
runs-on: ubuntu-latest | |
container: | |
image: jsii/superchain:1-buster-slim-node16 | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Setup Ruby | |
run: sudo apt-get update ; sudo apt-get install -y ruby | |
- name: Install dependencies | |
run: yarn install --check-files --frozen-lockfile | |
- name: Snapshot main | |
run: | | |
npm run bundle | |
npm run integ:default:snapshot | |
- name: Switch to branch | |
run: git checkout ${{ github.event.workflow_run.head_branch }} | |
- name: Install dependencies | |
run: yarn install --check-files --frozen-lockfile | |
- name: Snapshot branch | |
run: | | |
npm run bundle | |
npm run integ:default:snapshot | |
- name: Find mutations | |
id: create_patch | |
run: |- | |
git add . | |
git diff --staged --patch --exit-code || echo "patch_created=true" >> $GITHUB_OUTPUT | |
# upload snapshot (including assets from both main and branch) for easy diffing | |
- name: Diff | |
if: steps.create_patch.outputs.patch_created | |
working-directory: test/default.integ.snapshot | |
continue-on-error: true | |
run: |- | |
git diff --staged -U0 | grep '"path":' | cut -d '"' -f 4 | xargs -rL 2 diff -ruN > /tmp/assets.diff | |
- name: Upload assets.diff | |
if: steps.create_patch.outputs.patch_created | |
uses: actions/upload-artifact@v3 | |
with: | |
name: assets.diff | |
path: /tmp/assets.diff | |
- name: Upload snapshot | |
if: steps.create_patch.outputs.patch_created | |
uses: actions/upload-artifact@v3 | |
with: | |
name: snapshot | |
path: test/default.integ.snapshot | |
- name: Set git identity | |
if: steps.create_patch.outputs.patch_created | |
run: |- | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
# create a PR against the dependencies update PR for a proper snapshot | |
- name: Create Pull Request | |
if: steps.create_patch.outputs.patch_created | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
commit-message: |- | |
chore(deps): update snapshot | |
Update snapshot. See details in [workflow run]. | |
[Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "upgrade-snapshot" workflow* | |
branch: github-actions/upgrade-snapshot | |
title: "chore(deps): update snapshot for dependencies upgrade" | |
body: |- | |
Update snapshot. See details in [workflow run]. | |
[Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "upgrade-snapshot" workflow* | |
author: github-actions <[email protected]> | |
committer: github-actions <[email protected]> | |
signoff: true |