Skip to content

fledge

fledge #264

Workflow file for this run

name: fledge
on:
# for manual triggers
workflow_dispatch:
inputs:
pr:
description: "Create PR"
required: false
type: boolean
default: false
# daily run
schedule:
- cron: "30 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}
cancel-in-progress: true
jobs:
check_fork:
runs-on: ubuntu-24.04
outputs:
is_forked: ${{ steps.check.outputs.is_forked }}
steps:
- name: Check if the repo is forked
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
is_forked=$(gh api repos/${{ github.repository }} | jq .fork)
echo "is_forked=${is_forked}" >> $GITHUB_OUTPUT
shell: bash
fledge:
runs-on: ubuntu-24.04
needs: check_fork
if: needs.check_fork.outputs.is_forked == 'false'
permissions:
contents: write
pull-requests: write
actions: write
env:
FLEDGE_GHA_CI: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Configure Git identity
run: |
env | sort
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
shell: bash
- name: Update apt
run: |
sudo apt-get update
shell: bash
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
with:
pak-version: devel
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' || steps.rulesets.outputs.count > 0
run: |
git checkout -b fledge
git push -f -u origin HEAD
shell: bash
- name: Bump version
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
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' || steps.rulesets.outputs.count > 0
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -ex
if [ -n "$(git diff main --numstat)" ]; then
gh pr create --base main --head fledge --fill-first
gh workflow run rcc -f ref=$(git rev-parse HEAD)
gh pr merge --squash --auto
else
echo "No changes."
fi
shell: bash
- name: Check release
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
fledge:::release_after_cran_built_binaries()
shell: Rscript {0}