Skip to content

Commit

Permalink
ci: Trigger workflow run on vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Nov 30, 2024
1 parent 855230b commit 80748d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 46 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ on:
- main
paths:
- "data-raw/upgrade.R"
- ".github/workflows/upgrade.yaml"
workflow_dispatch:

name: upgrade

jobs:
upgrade:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

name: Upgrade bundled SQLite

Expand Down Expand Up @@ -84,8 +85,29 @@ jobs:
shell: bash

- name: Run preparation
id: vendor
run: |
R -q -f data-raw/upgrade.R
# Check if ahead of upstream branch
# If yes, set a step output
if [ $(git rev-list HEAD...origin/main --count) -gt 0 ]; then
# Avoid set-output, it's deprecated
echo "vendor=ok" >> "$GITHUB_OUTPUT"
fi
shell: bash

- name: Create PR
if: steps.vendor.outputs.vendor != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
git checkout -b vendor
if git push -u origin HEAD; then
gh pr create --fill-first
gh workflow run rcc -f ref=vendor
gh pr merge --auto --squash
fi
- name: Check rate limits
if: always()
Expand Down
45 changes: 0 additions & 45 deletions data-raw/upgrade.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,49 +87,4 @@ if (any(grepl("^src/", gert::git_status()$file))) {
# and still succeed
message("Pushing branch")
gert::git_push(force = TRUE)

message("Checking if PR exists")
existing_pr <- gh::gh(
"/repos/r-dbi/RSQLite/pulls",
head = paste0("r-dbi:", branch), base = old_branch,
state = "open"
)

if (length(existing_pr) > 0) {
message("Nudging")
gh::gh(
paste0("/repos/r-dbi/RSQLite/issues/", existing_pr[[1]]$number, "/comments"),
body = "PR updated.",
.method = "POST"
)
} else {
message("Opening PR")
pr <- gh::gh(
"/repos/r-dbi/RSQLite/pulls",
head = branch, base = old_branch,
title = title, body = ".",
.method = "POST"
)

message("Tweaking PR body")
body <- paste0("NEWS entry will be picked up by fledge from the PR title.")

gh::gh(
paste0("/repos/r-dbi/RSQLite/pulls/", pr$number),
body = body,
.method = "PATCH"
)

message("Adding label")
gh::gh(
paste0("/repos/r-dbi/RSQLite/issues/", pr$number),
labels = c("mergequeue", "mergequeue"),
.method = "PATCH"
)

message("Bumping main branch to run CI/CD")
gert::git_branch_checkout(old_branch)
system2("git", c("commit", "-m", "'chore: Bump main branch for CI/CD'", "--allow-empty"))
gert::git_push(force = FALSE)
}
}

0 comments on commit 80748d4

Please sign in to comment.