Skip to content

Commit 8e0c360

Browse files
committed
add nightly updating workflow
1 parent 3d8924a commit 8e0c360

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Update submodules to nightly.
2+
# .repos sync is not handled here (maybe run pre-commit once?)
3+
name: Update Nightly Submodules
4+
5+
on:
6+
schedule:
7+
- cron: '0 0 * * *' # Every day at 00:00 UTC
8+
workflow_dispatch:
9+
10+
jobs:
11+
update-nightly-submodules:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Generate token
23+
id: generate-token
24+
uses: tibdex/github-app-token@v2
25+
with:
26+
app_id: ${{ secrets.APP_ID }}
27+
private_key: ${{ secrets.PRIVATE_KEY }}
28+
29+
- name: Set git config
30+
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
31+
with:
32+
token: ${{ steps.generate-token.outputs.token }}
33+
34+
- name: Update nightly submodules
35+
id: update-nightly-submodules
36+
env:
37+
MAIN_BRANCH_NAME: main
38+
NIGHTLY_BRANCH_NAME: nightly
39+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
40+
run: |
41+
git checkout "${MAIN_BRANCH_NAME}"
42+
git checkout -B "${NIGHTLY_BRANCH_NAME}"
43+
44+
# Check if repository has submodules
45+
if [ ! -f .gitmodules ]; then
46+
echo "Error: The repository is not using git submodules"
47+
exit 1
48+
fi
49+
50+
git submodule update --init --checkout
51+
git submodule update --remote
52+
git add .
53+
git commit -m "chore: update nightly submodules from ${MAIN_BRANCH_NAME}" || echo "No submodule updates to commit"
54+
git push origin "${NIGHTLY_BRANCH_NAME}" --force-with-lease

0 commit comments

Comments
 (0)