-
Notifications
You must be signed in to change notification settings - Fork 85
89 lines (82 loc) · 2.9 KB
/
update_wallet_env.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
name: Update ckb node assume valid target
on:
create:
jobs:
ready-for-release:
name: Update ckb node assume valid target
runs-on: ubuntu-latest
environment: neuron-bot
permissions:
pull-requests: write # open PR
contents: write # update version files
if: ${{ startsWith(github.ref_name, 'rc/') }}
steps:
- name: Create Branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'chore-update-wallet-env/${{github.ref_name}}'
sha: '${{ github.sha }}'
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'chore-update-wallet-env/${{github.ref_name}}'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.15.1
- name: Write env file
run: |
npm run update:wallet-env
- name: Commit env file
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE: ${{ github.ref_name }}
with:
script: |
const fs = require('node:fs')
const { BASE, HEAD } = process.env
const envFilePath = 'packages/neuron-wallet/.env'
const destinationBranch = `chore-update-wallet-env/${BASE}`
const { data } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: envFilePath,
ref: destinationBranch,
})
await github.rest.repos.createOrUpdateFileContents({
owner: context.repo.owner,
repo: context.repo.repo,
path: envFilePath,
message: `chore: Update ckb node assume valid target for ${BASE}.`,
content: fs.readFileSync(envFilePath).toString('base64'),
sha: data.sha,
branch: destinationBranch,
})
- name: Create PR
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE: ${{github.ref}}
HEAD: chore-update-wallet-env/${{github.ref_name}}
REPO: ${{github.repository}}
with:
script: |
const { BASE, HEAD, REPO } = process.env
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
})
if (pulls.some(pull => pull.head.ref === HEAD)) {
return
}
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: HEAD,
base: BASE,
title: 'chore: Update ckb node assume valid target',
body: `This PR uses to update ckb node assume valid target for ${BASE} branch`,
})