Skip to content

Get latest release version #1065

Get latest release version

Get latest release version #1065

name: Get latest release version
on:
workflow_dispatch:
push:
paths:
- "version.txt"
schedule:
- cron: "0 0 * * *"
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- name: Send telegram notification
uses: appleboy/[email protected]
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
⚙️ Checking if new release is available.
📚 Repository: [ ${{ github.repository }} ](https://github.com/${{ github.repository }})
- name: Checkout
uses: actions/checkout@v4
with:
# Have to use custom PAT, because commits created with GITHUB_TOKEN will not trigger CI
# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- name: Fetch release version
id: version
env:
release_url: https://api.github.com/repos/hashicorp/terraform/releases/latest
run: |
curl -sL ${{ env.release_url }} | \
jq -r ".tag_name" > version.txt
echo "version=$(cat version.txt | tr -d 'v')" >> $GITHUB_OUTPUT
- name: Check for modified files
id: git-check
run: echo "modified=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" >> $GITHUB_OUTPUT
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git commit -am "Update release version to ${{ steps.version.outputs.version }}"
git push