Add .gitea/workflows/update.yaml
This commit is contained in:
64
.gitea/workflows/update.yaml
Normal file
64
.gitea/workflows/update.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
name: Auto Update Mullvad VPN Template
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 12 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update-template:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y curl jq
|
||||
|
||||
- name: Fetch Latest Stable Release
|
||||
id: get_release
|
||||
run: |
|
||||
RELEASES=$(curl -s https://api.github.com/repos/mullvad/mullvadvpn-app/releases?per_page=50)
|
||||
VERSION=$(echo "$RELEASES" | jq -r '[.[] | select(.tag_name | test("^\\d{4}\\.\\d+$"))] | sort_by(.published_at) | reverse | .[0].tag_name')
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
echo "No stable release found"
|
||||
exit 0
|
||||
fi
|
||||
DEB_URL=$(echo "$RELEASES" | jq -r "[.[] | select(.tag_name == \"$VERSION\")] | .[0].assets[] | select(.name | test(\".*amd64.*\\\\.deb$\")) | .browser_download_url")
|
||||
if [[ -z "$DEB_URL" ]]; then
|
||||
echo "No .deb found"
|
||||
exit 0
|
||||
fi
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "deb_url=$DEB_URL" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Read Current Version
|
||||
if: steps.get_release.outputs.version
|
||||
id: check_version
|
||||
run: |
|
||||
CURRENT_VERSION=$(grep '^version=' template | cut -d= -f2)
|
||||
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download and Checksum
|
||||
if: steps.get_release.outputs.version && steps.get_release.outputs.version != steps.check_version.outputs.current_version
|
||||
id: download
|
||||
run: |
|
||||
curl -Lo mullvad.deb "${{ steps.get_release.outputs.deb_url }}"
|
||||
SHA256=$(sha256sum mullvad.deb | awk '{print $1}')
|
||||
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update Template
|
||||
if: steps.get_release.outputs.version && steps.get_release.outputs.version != steps.check_version.outputs.current_version
|
||||
run: |
|
||||
sed -i "s/^version=.*/version=${{ steps.get_release.outputs.version }}/" template
|
||||
sed -i "s/^checksum=.*/checksum=${{ steps.download.outputs.sha256 }}/" template
|
||||
|
||||
- name: Commit and Push
|
||||
if: steps.get_release.outputs.version && steps.get_release.outputs.version != steps.check_version.outputs.current_version
|
||||
run: |
|
||||
git config user.name "Wizzard"
|
||||
git config user.email "rich@bandaholics.cash"
|
||||
git add template
|
||||
git commit -m "Update to v${{ steps.get_release.outputs.version }} [auto]"
|
||||
git push
|
||||
Reference in New Issue
Block a user