-
Notifications
You must be signed in to change notification settings - Fork 26
75 lines (64 loc) · 2.97 KB
/
check-updates.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: Automatic Package Update Check
on:
workflow_dispatch:
schedule:
- cron: "0 4 * * *"
jobs:
package_update_check:
if: github.repository_owner == 'eclipse-velocitas'
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.VELOCITAS_PROJECT_TOKEN }}
- name: Use devcontainer for upgrade and PR creation
uses: devcontainers/[email protected]
with:
runCmd: |
sudo apt-get update && sudo apt-get install -y gh
echo "${{ secrets.VELOCITAS_PROJECT_TOKEN }}" | gh auth login --with-token
velocitas upgrade --ignore-bounds && velocitas init && velocitas sync
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
PR_TITLE="Automated Package Update"
PR_BODY="This pull request was created automatically by GitHub Actions to update package versions."
# Check if a PR with the same title already exists
PR_EXISTING=$(gh pr list --state open --search "$PR_TITLE" --json number | jq -r '.[0].number // empty')
if [ -n "$PR_EXISTING" ]; then
echo "Existing PR found (#${PR_EXISTING}). Editing..."
git checkout .
gh pr checkout "$PR_EXISTING"
velocitas upgrade --ignore-bounds && velocitas init && velocitas sync
git add .
git commit -m "Update velocitas package versions"
if [ $? -eq 0 ]; then
git push
gh pr comment "$PR_EXISTING" --body "Updated PR with latest package updates"
fi
else
git add .
git commit -m "Update velocitas package versions"
BRANCH_NAME="automated-update-${{ github.sha }}"
git push origin HEAD:$BRANCH_NAME
echo "Creating new PR..."
gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head $BRANCH_NAME --base main
fi
else
echo "No changes detected. Skip creating Pull Request."
fi