Skip to content

Commit 4ea4fb4

Browse files
committed
Add Dependabot config and workflow to auto-update blueprint source_url.
1 parent e7c3343 commit 4ea4fb4

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Update Blueprint Source URL
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- "**.yaml"
10+
- "! .github/**"
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
update-url:
18+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Update URLs dynamically
30+
run: |
31+
BRANCH=${GITHUB_REF#refs/heads/}
32+
BASE_URL="https://github.com/${{ github.repository }}/blob/$BRANCH"
33+
34+
echo "Updating source_url for branch: $BRANCH"
35+
36+
find . -type f -name "*.yaml" ! -path "./.github/*" | while read -r file; do
37+
if grep -q "^ *source_url:" "$file"; then
38+
RELATIVE_PATH=$(echo "$file" | sed 's|^\./||')
39+
NEW_URL="${BASE_URL}/${RELATIVE_PATH}"
40+
41+
sed -i "s|^\( *\)source_url:.*|\1source_url: $NEW_URL|" "$file"
42+
43+
echo "Processed: $RELATIVE_PATH"
44+
fi
45+
done
46+
47+
- name: Commit and Push changes
48+
run: |
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
git add .
52+
53+
if ! git diff --quiet --staged; then
54+
git commit -m "chore: sync source_url to branch $BRANCH [skip ci]"
55+
git pull --rebase origin $BRANCH
56+
git push origin $BRANCH
57+
else
58+
echo "No changes to commit."
59+
fi

0 commit comments

Comments
 (0)