Skip to content

autoupdate for ttc #19687

autoupdate for ttc

autoupdate for ttc #19687

name: autoupdate for ttc
on:
# runs every hour
schedule:
- cron: "30 * * * *"
# 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/ttc-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
id: check
run: |
# get the latest version
LATEST_VERSION="${{ needs.get-latest-tag.outputs.tag }}"
echo latest version of jonz94/ttc-sarasa-gothic-nerd-fonts is ${LATEST_VERSION}
# get the current version
CURRENT_VERSION=$(grep "version \"" Casks/font-sarasa-nerd-font-ttc.rb | cut -d\" -f 2)
echo current version of sarasa-nerd-font-ttc 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-ttc:
name: Update TTC
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_for_ttc.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 sarasa-nerd-font-ttc from ${CURRENT_VERSION} to ${LATEST_VERSION}"
git push