Skip to content

Commit

Permalink
chore: add gyp-next updater
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed Dec 3, 2024
1 parent 0e6b6f8 commit 954a5c8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/update-gyp-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Update gyp-next

on:
schedule:
# Run once a week at 12:00 AM UTC on Sunday.
- cron: 0 0 * * *
workflow_dispatch:

permissions:
contents: read

env:
NODE_VERSION: lts/*

jobs:
update-gyp-next:
# if: github.repository == 'nodejs/node' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/github-script@v7
id: get-gyp-next-version
with:
script: |
const result = await github.rest.repos.getLatestRelease({
owner: 'nodejs',
repo: 'gyp-next',
});
return result.data.tag_name
result-encoding: string

- name: Update gyp-next
run: |
python update-gyp.py --no-commit ${{ steps.get-gyp-next-version.outputs.result }}
- name: Open or update PR for the gyp-next update
uses: gr2m/create-or-update-pull-request-action@v1
with:
branch: actions/update-gyp-next
author: Node.js GitHub Bot <github-bot@iojs.org>
title: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
commit-message: 'feat: update gyp-next to ${{ steps.get-gyp-next-version.outputs.result }}'
update-pull-request-title-and-body: true
body: >
This is an automated update of the gyp-next to
https://github.com/nodejs/gyp-next/releases/tag/${{ steps.get-gyp-next-version.outputs.result }}.
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
9 changes: 7 additions & 2 deletions update-gyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
CHECKOUT_GYP_PATH = os.path.join(CHECKOUT_PATH, "gyp")

parser = argparse.ArgumentParser()
parser.add_argument("--no-commit",
action="store_true",
dest="no_commit",
help="do not run git-commit")
parser.add_argument("tag", help="gyp tag to update to")
args = parser.parse_args()

Expand Down Expand Up @@ -60,5 +64,6 @@ def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
os.path.join(unzip_target, os.listdir(unzip_target)[0]), CHECKOUT_GYP_PATH
)

subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH)
subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag])
if not args.no_commit:
subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH)
subprocess.check_output(["git", "commit", "-m", "feat(gyp): update gyp to " + args.tag])

Check failure on line 69 in update-gyp.py

View workflow job for this annotation

GitHub Actions / Lint Python

Ruff (E501)

update-gyp.py:69:89: E501 Line too long (90 > 88)

0 comments on commit 954a5c8

Please sign in to comment.