build: fix autoroller (#672)

This commit is contained in:
Luca Casonato 2021-04-27 11:02:47 +02:00 committed by GitHub
parent 5de55ce795
commit e60f12798f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 17 deletions

View File

@ -11,11 +11,17 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v1
with:
fetch-depth: 10
submodules: recursive
- uses: denoland/setup-deno@main
with:
deno-version: v1.x
- name: Setup Git user
run: |
git config --global user.email "33910674+denobot@users.noreply.github.com"
git config --global user.name "denobot"
git config --global user.password ${{ secrets.DENOBOT_PAT }}
echo "GIT_USER=${{ secrets.DENOBOT_PAT }}" >> $GITHUB_ENV
git remote set-url origin https://${{ secrets.DENOBOT_PAT }}@github.com/denoland/rusty_v8.git
- run: deno run -A ./tools/auto_update_v8.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -22,11 +22,13 @@ function extractVersion() {
}
await run(["git", "checkout", "origin/main"]);
await run(["git", "submodule", "update", "--init", "--recursive", "v8"]);
const currentVersion = extractVersion();
console.log(`Starting auto update. Currently on ${currentVersion}`);
async function run(cmd: string[], cwd?: string) {
console.log("$", ...cmd);
const proc = Deno.run({ cmd, cwd });
const status = await proc.status();
if (!status.success) {
@ -36,6 +38,7 @@ async function run(cmd: string[], cwd?: string) {
}
// Update v8 submodule
await run(["git", "fetch", `origin`, V8_TRACKING_BRANCH], "./v8");
await run(["git", "checkout", `origin/${V8_TRACKING_BRANCH}`], "./v8");
const newVersion = extractVersion();
@ -61,30 +64,41 @@ await run(["git", "add", "v8", "README.md"]);
await run(["git", "commit", "-m", `Rolling to V8 ${newVersion}`]);
// Push to the `denoland/rusty_v8#autoroll`
await run(["git", "push", "origin", `+HEAD:${AUTOROLL_BRANCH}`]);
await run(["git", "push", "origin", `+HEAD:refs/heads/${AUTOROLL_BRANCH}`]);
// Fetch the remote branch so `gh` cli can find it
await run(["git", "fetch", "origin", AUTOROLL_BRANCH]);
const proc = Deno.run({
cmd: ["gh", "pr", "view", AUTOROLL_BRANCH],
cmd: ["gh", "pr", "view", AUTOROLL_BRANCH, "--json", "state"],
stdout: "piped",
});
const status = await proc.status();
if (status.code == 1) {
console.log("No PR open. Creating a new PR.");
await run([
"gh",
"pr",
"create",
"--fill",
"--head",
AUTOROLL_BRANCH,
]);
} else {
const isPrOpen = status.success
? JSON.parse(new TextDecoder().decode(await proc.output())).state === "OPEN"
: false;
if (isPrOpen) {
console.log("Already open PR. Editing existing PR.");
await run([
"gh",
"pr",
"edit",
AUTOROLL_BRANCH,
`denoland:${AUTOROLL_BRANCH}`,
"--title",
`Rolling to V8 ${newVersion}`,
]);
} else {
console.log("No PR open. Creating a new PR.");
await run([
"gh",
"pr",
"create",
"--title",
`Rolling to V8 ${newVersion}`,
"--body",
"",
"--head",
`denoland:${AUTOROLL_BRANCH}`,
]);
}