Skip to content

Commit

Permalink
Add auto update check for templates and trigger workflow from package…
Browse files Browse the repository at this point in the history
… release

Signed-off-by: Dennis Meister <[email protected]>
  • Loading branch information
dennismeister93 committed Jul 5, 2024
1 parent 35b40c5 commit f058f3c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/trigger_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Trigger Velocitas Update Workflow

on:
release:
types: [published]

env:
CHECK_UPDATES_FILE: check-updates.yml

jobs:
trigger:
strategy:
matrix:
# repo: ["vehicle-app-python-template", "vehicle-app-cpp-template", "vehicle-app-cpp-sdk"]
# Start with python template
repo: ["vehicle-app-python-template"]
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Trigger Workflow
run: |
echo "${{ secrets.GH_CLI_PAT }}" | gh auth login --with-token
gh workflow run $CHECK_UPDATES_FILE -R eclipse-velocitas/${{ matrix.repo }}
53 changes: 53 additions & 0 deletions src/common/workflows/check-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Package Updates

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
git add .
git commit -m "Update velocitas package versions"
BRANCH_NAME="automated-update-${{ github.sha }}"
git push origin HEAD:$BRANCH_NAME
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}). Closing..."
gh pr close "$PR_EXISTING" -d
fi
echo "Creating new PR..."
gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head $BRANCH_NAME --base main
else
echo "No changes detected. Skip creating Pull Request."
fi

0 comments on commit f058f3c

Please sign in to comment.