Skip to content

check_updates

check_updates #199

name: check_updates
on:
schedule:
# Check daily
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
check_updates:
runs-on: ubuntu-latest
if: github.repository_owner == 'thin-edge'
env:
CREATE_PR: 0
PR_BRANCH: updater
REPO: thinedge/tedge-release
steps:
- uses: actions/checkout@v4
- name: Check update
id: update
run: |
LATEST_VERSION=$(./scripts/admin.sh update_version --repo "$REPO" | tail -1)
echo "latest_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
- name: Create PR on new version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
git add -A . ||:
LATEST_VERSION="${{ steps.update.outputs.latest_version }}"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes detected. Current version=$LATEST_VERSION"
exit 0
fi
echo "Changes detected. New version=$LATEST_VERSION"
git status
git config --global user.email "[email protected]"
git config --global user.name "Versioneer"
if [ "$CREATE_PR" = 0 ]; then
echo "Committing to main"
git commit -am "Update version to $LATEST_VERSION"
git push --set-upstream origin main
else
echo "Creating PR"
git checkout -b "$PR_BRANCH"
git commit -am "Update version to $LATEST_VERSION"
git push --set-upstream origin "$PR_BRANCH"
gh repo set-default ${{github.repository}}
gh pr create --title "Update version: $LATEST_VERSION" --body "Update version"
fi