-
Notifications
You must be signed in to change notification settings - Fork 3
151 lines (133 loc) · 4.14 KB
/
renovate.yml
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
name: Renovate
on:
schedule:
- cron: '13 */8 * * *'
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run'
required: false
default: 'false'
concurrency:
group: renovate
jobs:
rest:
runs-on: ubuntu-24.04
outputs:
limit: ${{ steps.rate-limit.outputs.limit }}
remaining: ${{ steps.rate-limit.outputs.remaining }}
renovate: ${{ steps.rate-limit.outputs.renovate }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_RENOVATE }}
steps:
- name: Check rate limit
id: rate-limit
run: |
JSON="$(curl --silent --header "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/rate_limit)"
LIMIT="$(echo ${JSON} | jq --raw-output '.resources.graphql.limit')"
REMAINING="$(echo ${JSON} | jq --raw-output '.resources.graphql.remaining')"
RESET="$(echo ${JSON} | jq --raw-output '.resources.graphql.reset')"
echo "Rate limit: ${REMAINING}/${LIMIT} (reset: $(date --date=@${RESET}))"
echo "limit=${LIMIT}" >>"${GITHUB_OUTPUT}"
echo "remaining=${REMAINING}" >>"${GITHUB_OUTPUT}"
echo "reset=${RESET}" >>"${GITHUB_OUTPUT}"
if [ "${REMAINING}" -lt 1000 ]; then
echo "Rate limit exceeded"
echo "renovate=false" >>"${GITHUB_OUTPUT}"
else
echo "Rate limit sufficient"
echo "renovate=true" >>"${GITHUB_OUTPUT}"
fi
renovate:
runs-on: ubuntu-24.04
needs:
- rest
if: ${{ needs.rest.outputs.renovate == 'true' }}
permissions: write-all
steps:
- name: Restore cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: renovate/cache
key: renovate-cache
restore-keys: |
renovate-cache-${{ github.sha }}
renovate-cache-
- name: Prepare permissions
run: |
mkdir -p renovate/cache
docker run --rm \
--volume $PWD/renovate:/tmp/renovate \
ubuntu:22.04 \
chown -R 1000:0 /tmp/renovate
- name: Self-hosted Renovate
env:
LOG_LEVEL: debug
RENOVATE_TOKEN: ${{ secrets.BOT_RENOVATE }}
run: |
docker run --interactive --rm \
--env LOG_LEVEL \
--env RENOVATE_TOKEN="${RENOVATE_TOKEN}" \
--volume $PWD/renovate:/tmp/renovate \
renovate/renovate:slim \
--dry-run=${{ inputs.dry-run }} \
"${GITHUB_REPOSITORY}"
- name: Save cache
id: cache-save
uses: actions/cache/save@v4
with:
path: renovate/cache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}-${{ github.sha }}
check-log:
runs-on: ubuntu-24.04
needs:
- renovate
if: always()
env:
GITHUB_TOKEN: ${{ secrets.BOT_RENOVATE }}
steps:
- name: Fetch log
run: |
echo "### Processing run id ${{ github.run_id }}"
JOB_ID="$(
curl --url https://api.github.com/repos/uniget-org/tools/actions/runs/${{ github.run_id }}/jobs \
--silent \
--location \
--fail \
--header "Authorization: Bearer ${{ secrets.BOT_RENOVATE }}" \
| jq '.jobs[] | select(.name == "renovate") | .id'
)"
echo "### Fetching log for job id ${JOB_ID}"
curl --url https://api.github.com/repos/uniget-org/tools/actions/jobs/${JOB_ID}/logs \
--silent \
--location \
--fail \
--header "Authorization: Bearer ${{ secrets.BOT_RENOVATE }}" \
>job.log
- name: Store logs
uses: actions/upload-artifact@v4
with:
name: logs.zip
path: "job.log"
- name: Check log
run: |
if grep secondary job.log; then
exit 1
fi
check-post-rest:
runs-on: ubuntu-24.04
needs:
- renovate
if: always()
env:
GITHUB_TOKEN: ${{ secrets.BOT_RENOVATE }}
steps:
- name: Check rate limit
id: rate-limit
run: |
curl \
--url https://api.github.com/rate_limit \
--silent \
--header "Authorization: token ${GITHUB_TOKEN}" \
| jq .