-
Notifications
You must be signed in to change notification settings - Fork 19
39 lines (36 loc) · 1.38 KB
/
sync-version-with-upstream.yml
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
name: 🔄 Sync version with upstream
on:
# Runs at 10:00 UTC every day
schedule:
- cron: '0 10 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
sync-version:
name: "Update snapcraft.yaml"
environment: "Candidate Branch"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SNAPCRAFTERS_BOT_COMMIT }}
- name: Fetch release version
run: |
DEB_API="https://discord.com/api/download?platform=linux&format=deb"
DEB_URL=$(curl -w "%{url_effective}\n" -I -L -s -S "${DEB_API}" -o /dev/null)
VERSION=$(echo "${DEB_URL}" | cut -d'/' -f6)
sed -i 's/^\(version: \).*$/\1'"$VERSION"'/' snap/snapcraft.yaml
- name: Check for modified files
id: git-check
run: |
MODIFIED=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")
echo "modified=$MODIFIED" >> $GITHUB_OUTPUT
- name: Commit latest release version
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Snapcrafters Bot'
git config --global user.email '[email protected]'
git commit -am "Automatic sync to latest release"
git push
outputs:
modified: ${{ steps.git-check.outputs.modified }}