check_updates #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "info@thin-edge.io" | |
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 |