-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (48 loc) · 1.66 KB
/
check_updates.yaml
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
40
41
42
43
44
45
46
47
48
49
50
51
name: check_updates
on:
schedule:
# Check daily
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
check_updates:
runs-on: ubuntu-latest
if: github.repository_owner == 'reubenmiller'
env:
CREATE_PR: 0
PR_BRANCH: updater
REPO: thinedge/tedge-main
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