Skip to content

update-snapshot

update-snapshot #387

name: update-snapshot
on:
workflow_run:
workflows: [build]
types: [completed]
jobs:
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
env:
CI: "true"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- 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
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: git checkout "$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@v4
with:
name: assets.diff
path: /tmp/assets.diff
- name: Upload snapshot
if: steps.create_patch.outputs.patch_created
uses: actions/upload-artifact@v4
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@v6
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.event.workflow_run.head_branch }}-upgrade-snapshot
title: "chore(deps): update snapshot"
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