Update Livepeer Release Version #13
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: Update Livepeer Release Version | |
| on: | |
| schedule: | |
| # Run every 30 minutes | |
| - cron: "*/30 * * * *" | |
| workflow_dispatch: | |
| jobs: | |
| check-and-update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout docs repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get latest go-livepeer release | |
| id: get_release | |
| run: | | |
| LATEST_RELEASE=$(curl -s https://api.github.com/repos/livepeer/go-livepeer/releases/latest | jq -r .tag_name) | |
| echo "release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT | |
| echo "Latest release: ${LATEST_RELEASE}" | |
| - name: Read current version from globals.mdx | |
| id: current_version | |
| run: | | |
| CURRENT=$(grep -oP 'latestVersion\s*=\s*["'"'"']?\K[^"'"'"']+' snippets/automationData/globals/globals.mdx || echo "") | |
| echo "current=${CURRENT}" >> $GITHUB_OUTPUT | |
| echo "Current version: ${CURRENT}" | |
| - name: Update globals.mdx if needed | |
| if: | |
| steps.get_release.outputs.release != | |
| steps.current_version.outputs.current | |
| run: | | |
| # Create backup | |
| cp snippets/automationData/globals/globals.mdx snippets/automationData/globals/globals.mdx.bak | |
| # Update the latestVersion value | |
| sed -i "s/latestVersion[[:space:]]*=[[:space:]]*[\"'][^\"']*[\"']/latestVersion = \"${{ steps.get_release.outputs.release }}\"/" snippets/automationData/globals/globals.mdx | |
| # Update the latestVersionUrl value | |
| sed -i "s|latestVersionUrl[[:space:]]*=[[:space:]]*[\"'][^\"']*[\"']|latestVersionUrl = \"https://github.com/livepeer/go-livepeer/releases/download/${{ steps.get_release.outputs.release }}\"|" snippets/automationData/globals/globals.mdx | |
| # Verify the changes | |
| echo "Updated content:" | |
| grep "latestVersion" snippets/automationData/globals/globals.mdx | |
| - name: Commit and push if changed | |
| if: | |
| steps.get_release.outputs.release != | |
| steps.current_version.outputs.current | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add snippets/automationData/globals/globals.mdx | |
| git commit -m "chore: update latest release to ${{ steps.get_release.outputs.release }}" | |
| git push |