Update expected sha256sums #5
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 expected sha256sums | |
on: | |
workflow_dispatch: | |
inputs: | |
shas: | |
description: 'Expected sha256sums. Format is "<sha> node-v<version>-<os>-<arch>"' | |
required: true | |
type: string | |
jobs: | |
update: | |
permissions: | |
contents: write | |
pull-requests: write | |
strategy: | |
fail-fast: false # prevent test to stop if one fails | |
matrix: | |
node-version: [20] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
- name: Install deps | |
run: yarn install --ignore-engines | |
- name: Parses shas | |
id: parse-shas | |
run: | | |
echo "${{ inputs.shas }}\n" | while read -r sha patchName; do | |
# ensure sha and patchName are set | |
if [ -z "$sha" ] || [ -z "$patchName" ]; then | |
echo "Done" | |
continue | |
fi | |
echo "sha: $sha, patchName: $patchName" | |
# get node major, os and arch from patchName | |
major=$(echo $patchName | grep -oP 'node-v\K[0-9]+') | |
os=$(echo $patchName | grep -oP 'node-v[0-9.]+-(.*)-' | cut -d'-' -f3) | |
arch=$(echo $patchName | grep -oP 'node-v[0-9.]+-(.*)-(.*)' | cut -d'-' -f4) | |
if grep -E -q "$major\.([0-9.]+){2}-$os-$arch" shas.txt; then | |
sed -i -E "/$major\.([0-9.]+){2}-$os-$arch/c $sha $patchName" shas.txt | |
else | |
# if file doesn't end with a newline, add it | |
if [ "$(tail -c 1 shas.txt)" != "" ]; then | |
echo "" >> shas.txt | |
fi | |
echo "$sha $patchName" >> shas.txt | |
fi | |
done | |
- name: Update expected shas | |
run: | | |
yarn updateExpected | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "fix: update expected shas" | |
title: "fix: update expected shas" | |
body: "Update expected sha256sums for Node.js\n\n${{ inputs.shas }}" | |
branch: "update-expected-shas-${{ github.run_id }}" | |
base: "main" | |
delete-branch: true | |
labels: "chore, shas" | |
draft: false |