Check for new htmx release #20
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: Check for new htmx release | |
on: | |
schedule: | |
- cron: '0 0 * * Sun' | |
jobs: | |
check_release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get version from file | |
id: get_version_file | |
run: | | |
VERSION_FILE=$(curl -s https://raw.githubusercontent.com/Melkeydev/go-blueprint/main/cmd/template/advanced/files/htmx/htmx.min.js.tmpl | grep version | awk -F'"' '{print "v" $2}') | |
echo "version file: $VERSION_FILE" | |
if [[ "$VERSION_FILE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "version_file=$VERSION_FILE" >> $GITHUB_OUTPUT | |
else | |
echo "Invalid VERSION_FILE format: $VERSION_FILE" >&2 | |
exit 1 | |
fi | |
- name: Get version from GitHub API | |
id: get_version_api | |
run: | | |
VERSION_API=$(curl -s https://api.github.com/repos/bigskysoftware/htmx/releases/latest | jq -r '.tag_name') | |
echo "version api: $VERSION_API" | |
if [[ "$VERSION_API" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "version_api=$VERSION_API" >> $GITHUB_OUTPUT | |
else | |
echo "Invalid VERSION_API format: $VERSION_API" >&2 | |
exit 1 | |
fi | |
- name: Compare versions | |
id: compare_versions | |
run: | | |
if [ "${{ steps.get_version_api.outputs.version_api }}" != "${{ steps.get_version_file.outputs.version_file }}" ]; then | |
echo "release_changed=true" >> $GITHUB_OUTPUT | |
echo "Release changed: true" | |
else | |
echo "release_changed=false" >> $GITHUB_OUTPUT | |
echo "Release changed: false" | |
fi | |
- name: dump latest htmx version | |
if: steps.compare_versions.outputs.release_changed == 'true' | |
run: curl -L https://github.com/bigskysoftware/htmx/releases/latest/download/htmx.min.js -o cmd/template/advanced/files/htmx/htmx.min.js | |
- name: Prettify code | |
if: steps.compare_versions.outputs.release_changed == 'true' | |
run: | | |
npm install --save-dev --save-exact prettier | |
npx prettier --write cmd/template/advanced/files/htmx/htmx.min.js | |
rm -rf node_modules | |
rm package-lock.json | |
rm package.json | |
- name: Create tmpl after Prettify | |
if: steps.compare_versions.outputs.release_changed == 'true' | |
run: mv cmd/template/advanced/files/htmx/htmx.min.js cmd/template/advanced/files/htmx/htmx.min.js.tmpl | |
- name: Create Pull Request | |
if: steps.compare_versions.outputs.release_changed == 'true' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: update htmx version ${{ steps.get_version_api.outputs.version_api }} | |
title: Update htmx to version ${{ steps.get_version_api.outputs.version_api }} [Bot] | |
body: New htmx ${{ steps.get_version_api.outputs.version_api }} version is available. This is an automatic PR to update changes. | |
branch: htmx-version-update | |
base: main |