-
Notifications
You must be signed in to change notification settings - Fork 42
152 lines (133 loc) · 4.65 KB
/
Copy pathfledge.yaml
File metadata and controls
152 lines (133 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: fledge
on:
# for manual triggers
workflow_dispatch:
inputs:
pr:
description: "Create PR"
required: false
type: boolean
default: false
push:
branches:
- main
- master
paths:
- ".github/workflows/fledge.yaml"
# daily run
schedule:
- cron: "30 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}
cancel-in-progress: true
jobs:
check_news:
runs-on: ubuntu-26.04
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
# Fetch NEWS.md via API instead of full checkout for speed
- name: Check if not forked and NEWS.md mentions fledge
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euxo pipefail
# Check if repo is not forked
is_forked=$(gh api repos/${{ github.repository }} | jq .fork)
if [ "$is_forked" == "true" ]; then
echo "Repository is a fork. Skipping fledge workflow."
exit 0
fi
# Special case: duckdb and igraph
if [[ "${{ github.repository }}" == 'krlmlr/duckdb-r' ]]; then
echo "Repository is krlmlr/duckdb-r. Skipping fledge workflow."
exit 0
fi
if [[ "${{ github.repository }}" == 'krlmlr/rigraph' ]]; then
echo "Repository is krlmlr/rigraph. Skipping fledge workflow."
exit 0
fi
# Fetch NEWS.md content via API without full checkout
gh api repos/${{ github.repository }}/contents/NEWS.md --jq .content 2>/dev/null | base64 -d > /tmp/news.md || true
if [ ! -s /tmp/news.md ]; then
echo "NEWS.md not found. Skipping fledge workflow."
exit 0
fi
# Read first line of NEWS.md and check if it mentions fledge
news_content=$(head -n 1 /tmp/news.md)
if ! [[ "$news_content" == *"fledge"* ]]; then
echo "NEWS.md does not mention fledge. Skipping fledge workflow."
exit 0
fi
echo "should_run=true" >> $GITHUB_OUTPUT
shell: bash
fledge:
runs-on: ubuntu-26.04
needs: check_news
if: needs.check_news.outputs.should_run == 'true'
permissions:
contents: write
pull-requests: write
actions: write
env:
FLEDGE_GHA_CI: true
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- uses: ./.github/workflows/git-identity
- name: Update apt
run: |
sudo apt-get update
shell: bash
- uses: ./.github/workflows/install
with:
token: ${{ secrets.GITHUB_TOKEN }}
packages: ${{ github.repository == 'cynkra/fledge' && 'local::.' || '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}