create tag if QMK Firmware has new tag #5907
This file contains hidden or 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: create tag if QMK Firmware has new tag | |
| on: | |
| # runs every 6 hours | |
| schedule: | |
| - cron: "0 */6 * * *" | |
| # allow manually trigger | |
| workflow_dispatch: | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should-update: ${{ steps.check.outputs.should-update }} | |
| latest-tag: ${{ steps.check.outputs.latest-tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: check | |
| id: check | |
| run: | | |
| # get the latest tag | |
| LATEST_TAG=$(curl -fsSL 'https://shields.io/github/v/tag/qmk/qmk_firmware.json?sort=semver' | awk -F 'value' '{print $2}' | cut -d '"' -f 3 | cut -d 'v' -f 2) | |
| if [[ "${LATEST_TAG}" == "alid" ]]; then | |
| echo cannot get latest tag of qmk/qmk_firmware, skipping... | |
| exit 1 | |
| fi | |
| echo latest tag of qmk/qmk_firmware is ${LATEST_TAG} | |
| # check if we already have a matching tag | |
| if git rev-parse ${LATEST_TAG} >/dev/null 2>&1; then | |
| echo ${LATEST_TAG} tag exists, do nothing. | |
| echo "should-update=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo a newer version is available | |
| echo "should-update=true" >> $GITHUB_OUTPUT | |
| echo "latest-tag=${LATEST_TAG}" >> $GITHUB_OUTPUT | |
| tag: | |
| needs: check | |
| if: ${{ needs.check.outputs.should-update == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.WORKFLOW_PERSONAL_ACCESS_TOKEN }} | |
| - name: tag | |
| run: | | |
| LATEST_TAG="${{ needs.check.outputs.latest-tag }}" | |
| echo ${LATEST_TAG} tag does not exist, tag it to trigger next action. | |
| echo ${LATEST_TAG} > VERSION | |
| git config user.name 'github-actions[bot]' | |
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| make |