-
Notifications
You must be signed in to change notification settings - Fork 74
60 lines (50 loc) · 2.33 KB
/
update-livepeer-release.yml
File metadata and controls
60 lines (50 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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