Update ckb node assume valid target #92
Workflow file for this run
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 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`, | |
}) |