-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (74 loc) · 2.74 KB
/
update-node.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Update Node
on:
push:
branches: main
paths: .github/workflows/update-node.yml
schedule:
- cron: '0 15 * * 1-5'
workflow_dispatch:
permissions:
contents: read
concurrency: update-node
jobs:
update-node:
name: Update Node
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/[email protected]
- name: Determine info
shell: bash
id: info
run: |
OLD_VERSION=$(<.nvmrc)
NEW_VERSION=$(curl -sSf https://resolve-node.vercel.app/lts)
NEW_VERSION=${NEW_VERSION#'v'}
UPDATE_TITLE="chore(node): bump from $OLD_VERSION to $NEW_VERSION"
UPDATE_BODY="Bump Node from $OLD_VERSION to $NEW_VERSION."
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "update-title=$UPDATE_TITLE" >> $GITHUB_OUTPUT
echo "update-body=$UPDATE_BODY" >> $GITHUB_OUTPUT
- name: Update .nvmrc
run: echo "$NODE_VERSION" > .nvmrc
env:
NODE_VERSION: ${{steps.info.outputs.version}}
- name: Generate app token
id: app-token
uses: actions/[email protected]
with:
app-id: ${{secrets.GH_APP_ID}}
private-key: ${{secrets.GH_APP_PRIVATE_KEY}}
- name: Generate user info
id: user-info
run: |
USER_NAME="$GH_APP_SLUG[bot]"
USER_ID=$(gh api "/users/$USER_NAME" --jq .id)
USER_EMAIL="[email protected]"
echo "id=$USER_ID" >> $GITHUB_OUTPUT
echo "name=$USER_NAME" >> $GITHUB_OUTPUT
echo "[email protected]" >> $GITHUB_OUTPUT
echo "commit-author=$USER_NAME <$USER_EMAIL>" >> $GITHUB_OUTPUT
env:
GH_APP_SLUG: ${{steps.app-token.outputs.app-slug}}
GH_TOKEN: ${{steps.app-token.outputs.token}}
- name: Handle changes
uses: peter-evans/[email protected]
id: changes
with:
token: ${{steps.app-token.outputs.token}}
commit-message: ${{steps.info.outputs.update-title}}
author: ${{steps.user-info.outputs.commit-author}}
committer: ${{steps.user-info.outputs.commit-author}}
add-paths: .nvmrc
branch: auto/update-node
delete-branch: true
title: ${{steps.info.outputs.update-title}}
body: ${{steps.info.outputs.update-body}}
labels: auto,dependencies
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --rebase "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{steps.app-token.outputs.token}}