From 281e2f6aabf0413c4d9cc9d17bfc9af260e9ee54 Mon Sep 17 00:00:00 2001 From: Isa Farnik Date: Mon, 27 Feb 2023 11:42:40 -0800 Subject: [PATCH] feat(gha): add scheduled poll action --- .github/workflows/poll.yml | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/poll.yml diff --git a/.github/workflows/poll.yml b/.github/workflows/poll.yml new file mode 100644 index 0000000..963b6e6 --- /dev/null +++ b/.github/workflows/poll.yml @@ -0,0 +1,51 @@ +--- +name: Release + +on: # yamllint disable-line rule:truthy + schedule: + # wednesday, friday at 00:00 + - cron: '0 0 * * 3,5' + workflow_dispatch: + +jobs: + release: + name: Poll OpenSSL Website + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - env: + GITHUB_TOKEN: ${{ secrets.token }} + DEBUG: ${{ runner.debug == '1' && '1' || '' }} + run: | + if [ -n "${DEBUG:-}" ]; then + set -x + fi + + fresh="$( + grep -Eo -m1 -i '1\.1\.1.*available' <( + curl -Ls 'https://www.openssl.org/news/newslog.html' + ) | cut -d' ' -f1 + )" + + stale="$(cat .env)" + + message="chore(*): update OpenSSL to ${fresh}" + + if [[ "$fresh" != "$stale" ]] ; then + + # PR already created for fresh version + if gh pr list | grep "$message"; then + exit 0 + fi + + git checkout -b chore/openssl-${fresh} + + echo "$fresh" > .env + git add .env + git commit -m "chore(*): update OpenSSL to ${fresh}" + + pr="$(gh pr create --fill | grep -Eo '\d+$')" + + gh pr merge --auto "$pr" + fi