-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automation: Add GitHub action to schedule issue for submodule update. c…
…lose #38
- Loading branch information
Tzanko Matev (aider)
committed
Sep 5, 2024
1 parent
b9c7b4b
commit dea5cec
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Create Submodule Update Issue | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 */15 * *' # Run every 15 days | ||
workflow_dispatch: # Allow manual triggering | ||
|
||
|
||
permissions: | ||
issues: write | ||
contents: read | ||
|
||
jobs: | ||
create-issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Parse .gitmodules and create issue | ||
uses: actions/github-script@v7 | ||
with: | ||
|
||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
// Read and parse .gitmodules file | ||
const gitmodulesPath = path.join(process.env.GITHUB_WORKSPACE, '.gitmodules'); | ||
const gitmodulesContent = fs.readFileSync(gitmodulesPath, 'utf8'); | ||
// Extract submodule paths | ||
const submodules = gitmodulesContent.match(/path = .+/g).map(line => line.split(' = ')[1].trim()); | ||
// Create checkbox list | ||
const checkboxList = submodules.map(submodule => `- [ ] ${submodule}`).join('\n'); | ||
// Create issue | ||
await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: 'Update Submodules', | ||
body: `It's time to update the submodules. Please check for updates and merge them if necessary. | ||
Submodules to update: | ||
${checkboxList}`, | ||
labels: ['maintenance'] | ||
}); |