forked from Zibbp/ganymede
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (70 loc) · 2.75 KB
/
update-versions.yml
File metadata and controls
87 lines (70 loc) · 2.75 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Update Dependency Versions
on:
schedule:
- cron: "0 21 * * 1" # every Monday at 6 AM UTC
workflow_dispatch:
jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install jq
run: sudo apt-get install -y jq
- name: Update versions in Dockerfile
run: |
set -e
FILES=("Dockerfile" ".devcontainer/Dockerfile")
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | jq -r .tag_name
}
yt_dlp_ver=$(get_latest_release yt-dlp/yt-dlp)
twitch_ver=$(get_latest_release lay295/TwitchDownloader)
echo "Latest yt-dlp: $yt_dlp_ver"
echo "Latest twitchdownloader: $twitch_ver"
for FILE in "${FILES[@]}"; do
echo "Updating $FILE..."
sed -i -E "s/^(ARG YT_DLP_VERSION=\").*\"/\1$yt_dlp_ver\"/" "$FILE"
sed -i -E "s/^(ARG TWITCHDOWNLOADER_VERSION=\").*\"/\1$twitch_ver\"/" "$FILE"
done
- name: Commit changes
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
BRANCH="ci-update-versions-$(date +'%Y%m%d%H%M%S')"
if git diff --quiet; then
echo "No changes"
echo "commit_needed=false" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT
else
echo "Changes detected:"
git diff
# Delete existing local branch if needed
if git show-ref --verify --quiet refs/heads/$BRANCH; then
git branch -D $BRANCH
fi
# Optional: delete remote branch if it exists
if git ls-remote --exit-code --heads origin $BRANCH > /dev/null; then
git push origin --delete $BRANCH
fi
git checkout -b $BRANCH
git add Dockerfile .devcontainer/Dockerfile
git commit -m "Update ARG package versions in Dockerfile"
git push --set-upstream origin $BRANCH
echo "commit_needed=true" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT
fi
- name: Create pull request
if: steps.commit.outputs.commit_needed == 'true'
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update ARG versions in Dockerfile
title: "Update ARG versions in Dockerfile"
body: |
Automatically updated versions of:
- yt-dlp
- TwitchDownloader
branch: ${{ steps.commit.outputs.branch_name }}
base: main