diff --git a/.github/workflows/check-releases.yml b/.github/workflows/check-releases.yml index f444f34..b108042 100644 --- a/.github/workflows/check-releases.yml +++ b/.github/workflows/check-releases.yml @@ -1,7 +1,5 @@ name: Check for Hugo releases -# TODO: instead of failing CI, send a notification via email/slack/twilio/etc. - on: schedule: - cron: '0 */3 * * *' # run every three hours @@ -10,31 +8,33 @@ on: jobs: check: runs-on: ubuntu-latest - env: - # https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ - ACTIONS_ALLOW_UNSECURE_COMMANDS: true steps: - name: Get latest Hugo version + id: hugo_version # https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c run: | - HUGO_VERSION=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') - echo "::set-env name=HUGO_VERSION::$HUGO_VERSION" + HUGO_VERSION=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | tr -d "v") + echo "::set-output name=VERSION::$HUGO_VERSION" - name: Get latest package version + id: package_version run: | - PACKAGE_VERSION=v$(npm show hugo-extended version) # prepend v to match above format - echo "::set-env name=PACKAGE_VERSION::$PACKAGE_VERSION" + PACKAGE_VERSION=$(npm show hugo-extended version) + echo "::set-output name=VERSION::$PACKAGE_VERSION" - name: Compare versions + id: update run: | - echo "Current Hugo version is $HUGO_VERSION." - echo "Current package version is $PACKAGE_VERSION." + echo "Current package version is v${{ steps.package_version.outputs.VERSION }}." + echo "Current Hugo version is v${{ steps.hugo_version.outputs.VERSION }}." - if [ "$HUGO_VERSION" != "$PACKAGE_VERSION" ] + if [ "${{ steps.hugo_version.outputs.VERSION }}" != "${{ steps.package_version.outputs.VERSION }}" ] then echo "🚨 Needs updating!" - echo "::set-env name=UPDATE_AVAILABLE::true" + echo "::set-output name=UPDATE_AVAILABLE::true" exit 1 else echo "✅ All good for now." - echo "::set-env name=UPDATE_AVAILABLE::false" + echo "::set-output name=UPDATE_AVAILABLE::false" exit 0 fi + +# TODO: Automatically bump npm package, commit back to repo, and publish new version.