-
Notifications
You must be signed in to change notification settings - Fork 2.9k
96 lines (84 loc) · 2.75 KB
/
create-cli-deps-pr.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: "Create CLI Deps PR"
on:
workflow_dispatch:
inputs:
npmVersion:
description: "6.x.x or latest"
required: true
default: 'latest'
dryRun:
description: "Do a dry run?"
default: ''
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Checkout npm/node
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
repository: npm/node
token: ${{ secrets.NODE_PULL_REQUEST_TOKEN }}
- name: Setup git user
run: |
git config --global user.email "npm CLI robot"
git config --global user.name "npm-cli+bot@github.com"
- name: Sync upstream changes
uses: aormsby/Fork-Sync-With-Upstream-action@v3.2
with:
target_sync_branch: main
target_repo_token: ${{ secrets.NODE_PULL_REQUEST_TOKEN }}
upstream_sync_branch: main
upstream_sync_repo: nodejs/node
upstream_pull_args: --ff-only
- name: Run dependency updates and create PR
env:
GITHUB_TOKEN: ${{ secrets.NODE_PULL_REQUEST_TOKEN }}
run: |
base_dir="$( pwd )"/
dry_run="${{ github.event.inputs.dryRun }}"
npm_version="${{ github.event.inputs.npmVersion }}"
npm_tag=""
base_branch=""
if [ "$npm_version" == "latest" ]; then
npm_tag=`npm view npm@latest version`
base_branch="main"
else
npm_tag="$npm_version"
base_branch="v14.x-staging"
fi
npm_vtag="v$npm_tag"
npm_branch="npm-$npm_tag"
message="deps: upgrade npm to $npm_tag"
git checkout -b "$npm_branch"
echo "Cloning CLI repo"
gh repo clone npm/cli
echo "Prepping CLI repo for release"
cd cli
git checkout "$npm_vtag"
make release
echo "Removing old npm"
deps_dir="$base_dir"deps/
cd "$deps_dir"
rm -rf npm/
echo "Copying new npm"
tar zxf "$base_dir"cli/release/"$npm_branch".tgz
echo "Removing CLI workspace"
cd "$base_dir"
rm -rf cli
git add -A deps/npm
git commit -m "$message"
git rebase --whitespace=fix main
if [[ "$dry_run" == "true" ]]; then
git status
git show --summary
echo $message
echo $npm_branch
echo $base_branch
echo $npm_vtag
else
git push origin "$npm_branch"
gh release view "$npm_vtag" -R npm/cli --json body -q ".body" | \
gh pr create -R nodejs/node -B "$base_branch" -H "npm:$npm_branch" -t "$message" -F -
fi