Skip to content

Tailscale updater

Tailscale updater #69

name: Tailscale updater
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-tailscale:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: trunk
- name: Determine versions
id: compare
run: |
latest_tarball="$(curl -fsSL https://pkgs.tailscale.com/stable/?mode=json | jq -r '.TarballsVersion')"
if [ -z "$latest_tarball" ]; then
echo "Error: Failed to fetch latest Tailscale version" >&2
exit 1
fi
current_full="$(jq -r '.tailscaleVersion' plugin/plugin.json)"
current_tarball="${current_full#tailscale_}"
current_tarball="${current_tarball%_amd64}"
echo "latest=${latest_tarball}" >> "$GITHUB_OUTPUT"
echo "current=${current_tarball}" >> "$GITHUB_OUTPUT"
if [ "$latest_tarball" != "$current_tarball" ]; then
echo "update=true" >> "$GITHUB_OUTPUT"
else
echo "update=false" >> "$GITHUB_OUTPUT"
fi
- name: Stop when up to date
if: steps.compare.outputs.update != 'true'
run: echo "Tailscale is already up to date."
- name: Update plugin metadata
if: steps.compare.outputs.update == 'true'
id: plugin
run: |
new_full="tailscale_${{ steps.compare.outputs.latest }}_amd64"
sha_url="https://pkgs.tailscale.com/stable/tailscale_${{ steps.compare.outputs.latest }}_amd64.tgz.sha256"
new_sha="$(curl -fsSL "$sha_url" | cut -d' ' -f1)"
tmp="$(mktemp)"
jq --arg version "$new_full" --arg sha "$new_sha" \
'.tailscaleVersion=$version | .tailscaleSHA256=$sha' \
plugin/plugin.json > "$tmp"
mv "$tmp" plugin/plugin.json
echo "full_version=$new_full" >> "$GITHUB_OUTPUT"
echo "sha=$new_sha" >> "$GITHUB_OUTPUT"
- name: Commit and push branch
if: steps.compare.outputs.update == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B chore/tailscale-update
git add plugin/plugin.json
if git commit -m "chore: update Tailscale to ${{ steps.compare.outputs.latest }}"; then
git push --force origin chore/tailscale-update
echo "commit_made=true" >> $GITHUB_ENV
else
echo "No changes to commit."
echo "commit_made=false" >> $GITHUB_ENV
fi
- name: Create or update PR
if: steps.compare.outputs.update == 'true' && env.commit_made == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "chore: update Tailscale to ${{ steps.compare.outputs.latest }}" \
--body "Automated update via workflow." \
--head chore/tailscale-update \
--base trunk \
--label chore \
|| gh pr edit chore/tailscale-update \
--title "chore: update Tailscale to ${{ steps.compare.outputs.latest }}" \
--body "Automated update via workflow."