-
Notifications
You must be signed in to change notification settings - Fork 304
73 lines (64 loc) · 2.95 KB
/
update-htmx-version.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
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