Poll #196
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |