From 885df656393fe540797a880fc068d39deaec7cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 21 Nov 2024 06:42:00 +0100 Subject: [PATCH 1/2] ci: Correctly detect branch protection --- .github/workflows/fledge.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fledge.yaml b/.github/workflows/fledge.yaml index 02e9101..b197fb3 100644 --- a/.github/workflows/fledge.yaml +++ b/.github/workflows/fledge.yaml @@ -72,8 +72,18 @@ jobs: packages: cynkra/fledge cache-version: fledge-1 + - name: Count rulesets + # Assume that branch is protected if ruleset exists + id: rulesets + env: + GH_TOKEN: ${{ github.token }} + run: | + n_rulesets=$(gh api repos/${{ github.repository }}/rulesets -q length) + echo "count=${n_rulesets}" >> $GITHUB_OUTPUT + shell: bash + - name: Switch to branch if branch protection is enabled - if: github.ref_protected == 'true' || inputs.pr == 'true' + if: github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 run: | git checkout -b fledge git push -f -u origin HEAD @@ -83,14 +93,14 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} run: | - check_default_branch <- ("${{ github.ref_protected == 'true' || inputs.pr == 'true' }}" != "true") + check_default_branch <- ("${{ github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 }}" != "true") if (fledge::bump_version(which = "dev", no_change_behavior = "noop", check_default_branch = check_default_branch)) { fledge::finalize_version(push = TRUE) } shell: Rscript {0} - name: Create and merge PR if branch protection is enabled - if: github.ref_protected == 'true' || inputs.pr == 'true' + if: github.ref_protected == 'true' || inputs.pr == 'true' || steps.rulesets.outputs.count > 0 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | From bc1295c0c1043f259ef84ce82a9331a472276de6 Mon Sep 17 00:00:00 2001 From: krlmlr Date: Thu, 21 Nov 2024 05:47:51 +0000 Subject: [PATCH 2/2] chore: Auto-update from GitHub Actions Run: https://github.com/tidyverse/hms/actions/runs/11947405486 --- .github/dep-suggests-matrix.json | 1 - .github/versions-matrix.json | 1 - 2 files changed, 2 deletions(-) delete mode 100644 .github/dep-suggests-matrix.json delete mode 100644 .github/versions-matrix.json diff --git a/.github/dep-suggests-matrix.json b/.github/dep-suggests-matrix.json deleted file mode 100644 index b8c4507..0000000 --- a/.github/dep-suggests-matrix.json +++ /dev/null @@ -1 +0,0 @@ -{"package":["lubridate"]} diff --git a/.github/versions-matrix.json b/.github/versions-matrix.json deleted file mode 100644 index 5af4434..0000000 --- a/.github/versions-matrix.json +++ /dev/null @@ -1 +0,0 @@ -{"include":[{"os":"macos-latest","r":"4.4"},{"os":"macos-latest","r":"4.3"},{"os":"windows-latest","r":"devel"},{"os":"windows-latest","r":"4.4"},{"os":"windows-latest","r":"4.3"},{"os":"ubuntu-22.04","r":"devel","http-user-agent":"release"},{"os":"ubuntu-22.04","r":"4.4"},{"os":"ubuntu-22.04","r":"4.3"},{"os":"ubuntu-22.04","r":"4.2"},{"os":"ubuntu-22.04","r":"4.1"},{"os":"ubuntu-22.04","r":"4.0"},{"os":"ubuntu-22.04","r":"4.4","covr":"true","desc":"with covr"}]}