diff --git a/.github/workflows/upgrade.yaml b/.github/workflows/upgrade.yaml index cdfb0c61a..6cd7aefa2 100644 --- a/.github/workflows/upgrade.yaml +++ b/.github/workflows/upgrade.yaml @@ -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 @@ -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() diff --git a/data-raw/upgrade.R b/data-raw/upgrade.R index 7f15d4672..157789722 100644 --- a/data-raw/upgrade.R +++ b/data-raw/upgrade.R @@ -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) - } }