Skip to content

autoupdate

autoupdate #25763

Workflow file for this run

name: autoupdate
on:
# runs every hour
schedule:
- cron: "0 * * * *"
# allow manually trigger
workflow_dispatch:
concurrency: ${{ github.workflow }}
jobs:
get-latest-tag:
name: Get latest tag
runs-on: ubuntu-latest
outputs:
tag: ${{ env.TAG }}
steps:
- name: Get latest release
uses: octokit/request-action@v2.x
id: get_latest_release
with:
route: GET /repos/jonz94/Sarasa-Gothic-Nerd-Fonts/releases/latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get the latest tag without v prefix
run: |
TAG_WITH_V_PREFIX=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}
echo "TAG=${TAG_WITH_V_PREFIX#v}" >> $GITHUB_ENV
- name: Summary
run: |
echo "Latest tag without v prefix is $TAG"
check:
name: Check
needs: get-latest-tag
runs-on: ubuntu-latest
outputs:
should-update: ${{ env.SHOULD_UPDATE }}
latest-version: ${{ env.LATEST_VERSION }}
current-version: ${{ env.CURRENT_VERSION }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: check
run: |
# get the latest version
LATEST_VERSION="${{ needs.get-latest-tag.outputs.tag }}"
echo latest version of jonz94/Sarasa-Gothic-Nerd-Fonts is ${LATEST_VERSION}
# get the current version
CURRENT_VERSION=$(grep "version \"" Casks/font-sarasa-mono-tc-nerd-font.rb | cut -d\" -f 2)
echo current version of jonz94/homebrew-sarasa-nerd-fonts is ${CURRENT_VERSION}
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
if [[ "$LATEST_VERSION" == "$CURRENT_VERSION" ]]; then
echo everything is up to date!
echo "SHOULD_UPDATE=false" >> $GITHUB_ENV
else
echo a newer version is available
echo "SHOULD_UPDATE=true" >> $GITHUB_ENV
fi
update:
name: Update
needs: check
if: ${{ needs.check.outputs.should-update == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_PERSONAL_ACCESS_TOKEN }}
- name: update
run: |
bash -e developer/bin/generate_cask.sh
LATEST_VERSION="${{ needs.check.outputs.latest-version }}"
CURRENT_VERSION="${{ needs.check.outputs.current-version }}"
git status
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
git commit -m "πŸ€– ci: update from ${CURRENT_VERSION} to ${LATEST_VERSION}"
git push