Skip to content

Get latest release #160

Get latest release

Get latest release #160

name: Get latest release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
actions: write
contents: write
packages: write
id-token: write
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Fetch release version
run: |
git fetch
git pull
curl -sL https://api.github.com/repos/hashicorp/consul/releases/latest | \
jq -r ".tag_name" > .github/workflows/release_version/latest.txt
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "New Consul release version `cat .github/workflows/release_version/latest.txt`"
git push origin main
# git config --global user.name ${{ secrets.GH_USERNAME }}
# git config --global user.email ${{ secrets.GH_MAIL }}
# git pull --ff-only
# git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/hashicorp-education/learn-consul-tutorial-testing-phase-0