generated from Kong/template-github-release
-
Notifications
You must be signed in to change notification settings - Fork 3
108 lines (89 loc) · 2.63 KB
/
poll.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
---
name: Poll
on: # yamllint disable-line rule:truthy
schedule:
# wednesday, friday at 00:00
- cron: 0 0 * * 3,5
workflow_dispatch:
inputs:
force:
type: boolean
default: false
description: force PR creation
debug:
type: boolean
default: false
description: enable debug output
version:
type: string
required: false
description: manually supply openssl version
jobs:
release:
name: Refresh OpenSSL Version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Check OpenSSL Website
id: site
if: inputs.version == ''
run: |
if ${{ inputs.debug }} || [ -n "${DEBUG:-}" ]; then
set -x
fi
set -eo pipefail
fresh="$(
grep -Eo -m1 -i '1\.1\.1.*available' <(
curl -Ls 'https://www.openssl.org/news/newslog.html'
) | cut -d' ' -f1
)"
echo "fresh=${fresh}" >> $GITHUB_OUTPUT
- name: Create PR
env:
GITHUB_TOKEN: ${{ github.token }}
DEBUG: ${{ runner.debug == '1' && '1' || '' }}
run: |
if ${{ inputs.debug }} || [ -n "${DEBUG:-}" ]; then
set -x
fi
if [ -n '${{ inputs.version }}' ]; then
fresh='${{ inputs.version }}'
else
fresh=${{ steps.site.outputs.version }}
fi
source .env
stale="$OPENSSL_VERSION"
message="chore(*): update OpenSSL to ${fresh}"
branch="chore/openssl-${fresh}"
if ${{ inputs.force }} || [[ "$fresh" != "$stale" ]]; then
# PR already created for fresh version
if gh pr list | grep "$message"; then
exit 0
fi
gh auth setup-git
git config user.name github-actions
git config user.email [email protected]
git checkout -b "$branch"
echo "OPENSSL_VERSION=${fresh}" > .env
git add .env
git commit -m "chore(*): update OpenSSL to ${fresh}"
git diff
git push origin "$branch"
gh pr create \
--head "$branch" \
--title "$message" \
--body "$(
echo -e "### Summary\n\nUpdate to ${fresh}. Generated by GitHub Actions."
)"
pr="$(
gh pr list | grep "$(
# escape asterisk
echo "$message" | sed -e 's@\*@\\*@'
)" | cut -d$'\t' -f1
)"
# enable automerge
gh pr merge --auto --rebase "$pr"
fi