Update #1
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 | |
on: workflow_dispatch | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup nodejs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Checkout repository (hnsd) | |
uses: actions/checkout@v4 | |
with: | |
path: hnsd | |
- name: Checkout repository (hs-names) | |
uses: actions/checkout@v4 | |
with: | |
repository: handshake-org/hs-names | |
path: hs-names | |
- name: Install dependencies (hs-names) | |
run: npm --prefix=hs-names install | |
- name: Install dependencies (hsd) | |
run: npm --prefix=hs-names install hsd@^5 | |
- name: Build | |
run: | | |
cd hs-names | |
./download | |
# Workaround for https://github.com/chjj/bns/issues/41 | |
sed -i '/ZONEMD/d' data/root.zone | |
./zone.js | |
./zone-build.js | |
- name: Commit/PR | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const branch = `update-${new Date().getTime()}`; | |
const ref = `refs/heads/${branch}`; | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref, | |
sha: context.sha | |
}); | |
const fileOptions = { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
path: 'src/tld.h', | |
}; | |
const file = await github.rest.repos.getContent({ | |
...fileOptions, | |
ref | |
}); | |
await github.rest.repos.createOrUpdateFileContents({ | |
...fileOptions, | |
message: 'Update tld.h', | |
content: Buffer.from(fs.readFileSync('hs-names/build/tld.h')).toString('base64'), | |
sha: file.data.sha, | |
branch | |
}); | |
await github.rest.pulls.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: 'Update tld.h', | |
head: branch, | |
base: 'master' | |
}); |