chore: add GHA to update Nock files (#175)

This commit is contained in:
Antoine du Hamel 2022-09-02 11:08:05 +02:00
parent 2ede2b15ca
commit 3ca40140a5
No known key found for this signature in database
GPG Key ID: 21D900FFDB233756
1 changed files with 76 additions and 0 deletions

76
.github/workflows/update-nock-files.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: Update Nock files
on:
workflow_dispatch:
inputs:
pr_id:
description: PR ID
type: number
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: refs/pull/${{ inputs.pr_id }}/head
- name: Install Node
uses: actions/setup-node@v3
with:
# Let's use the oldest version supported to be sure the V8
# serialization is compatible with all supported versions.
node-version: 14.x
- name: Get the Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(corepack yarn config get cacheFolder)"
- uses: actions/cache@v3
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: |
${{runner.os}}-yarn-
- run: corepack yarn install --immutable
- run: corepack yarn build # We need the stubs to run the tests
- name: Remove old Nock files to avoid conflicts
run: rm -r tests/nock
- run: corepack yarn test
env:
NOCK_ENV: record
- name: Check if anything has changed
id: contains-changes
run: echo "::set-output name=result::$(git --no-pager diff --quiet -- tests/nock || echo "yes")"
- name: Commit changes
if: ${{ steps.contains-changes.outputs.result == 'yes' }}
run: |
git add tests/nock/
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git commit -m "update Nock files"
- name: Push changes
if: ${{ steps.contains-changes.outputs.result == 'yes' }}
run: >
gh api
-H "Accept: application/vnd.github+json"
/repos/${{ github.repository }}/pulls/${{ inputs.pr_id }}
--jq '"git push " + .head.repo.clone_url + " HEAD:refs/heads/" + .head.ref' | sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload `tests/nock` in case of failure
uses: actions/upload-artifact@v3
if: ${{ failure() && steps.contains-changes.outputs.result == 'yes' }}
with:
name: nock
path: |
tests/nock