Skip to content

Check Update(onecomme) #460

Check Update(onecomme)

Check Update(onecomme) #460

name: Check Update(onecomme)
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *'
jobs:
check-update:
name: Check Update
runs-on: ubuntu-latest
env:
CASK_NAME: OneComme
CASK_ID: onecomme
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Prepare
run: |
curl -L -o /tmp/pup.zip "https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip"
unzip -qq -d /tmp /tmp/pup.zip
- name: Check latest version
run: |
latest_version=$(curl -s "https://onecomme.com/" | /tmp/pup 'p.version_FnRn > strong text{}' | tail -n 1)
echo "latest version: ${latest_version}"
echo "latest_version=${latest_version}" >> $GITHUB_ENV
- name: Check cask version
run: |
cask_version=$(grep -oE "[0-9]+(\.[0-9]+){1,2}" "./Casks/${CASK_ID}.rb" | head -n 1)
echo "cask version: ${cask_version}"
echo "cask_version=${cask_version}" >> $GITHUB_ENV
- name: Replace
if: env.latest_version != env.cask_version
run: |
# replace version name
sed -i "s/${cask_version}/${latest_version}/g" "./Casks/${CASK_ID}.rb"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
if: env.latest_version != env.cask_version
with:
delete-branch: true
title: Update ${{ env.CASK_NAME }} to ${{ env.latest_version }}
commit-message: Update ${{ env.CASK_NAME }} to ${{ env.latest_version }}