Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ updates:
dev-dependencies:
patterns:
- "*"

- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "weekly"
labels:
- "submodule-update"
30 changes: 30 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Dependabot auto-approve and merge
on: pull_request

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'submodule-update') }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Approve PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97 changes: 97 additions & 0 deletions .github/workflows/dependabot-submodule-handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Handle Dependabot Submodule Updates
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'binding/voicevox_core'
branches:
- 'main'

jobs:
update-hash:
if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'submodule-update') }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}
submodules: recursive
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false

- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Update commit hash
id: update-hash
run: |
# Get the updated commit hash from voicevox_core submodule
NEW_HASH=$(cd binding/voicevox_core && git rev-parse HEAD)

# Update the hash in the props file
sed -i.bak "s/<VoicevoxCoreCommitHash>.*<\/VoicevoxCoreCommitHash>/<VoicevoxCoreCommitHash>$NEW_HASH<\/VoicevoxCoreCommitHash>/" src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props

# Check if there are changes
if [[ $(git diff --name-only) != "" ]]; then
echo "Hash updated to $NEW_HASH"
echo "hash_updated=true" >> $GITHUB_OUTPUT
else
echo "No hash changes needed"
echo "hash_updated=false" >> $GITHUB_OUTPUT
fi

- name: Setup Rust toolchain
uses: actions-rust-lang/[email protected]
if: ${{ steps.update-hash.outputs.hash_updated == 'true' }}

- name: Generate bindings
if: ${{ steps.update-hash.outputs.hash_updated == 'true' }}
working-directory: ./binding
run: make generate

- name: Check for code generation changes
id: binding-diff
if: ${{ steps.update-hash.outputs.hash_updated == 'true' }}
run: |
if [[ $(git diff --name-only | grep .cs$) != "" ]]; then
echo "binding_has_update=true" >> $GITHUB_OUTPUT
echo "Code generation changes detected. Manual review required."
else
echo "binding_has_update=false" >> $GITHUB_OUTPUT
fi

- name: Commit changes
if: ${{ steps.update-hash.outputs.hash_updated == 'true' && steps.binding-diff.outputs.binding_has_update != 'true' }}
run: |
git add src/VoicevoxCoreSharp.Core/VoicevoxCoreSharp.Core.Metas.props
git commit -m "Update VoicevoxCore commit hash"
git config --global url."https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com".insteadOf "https://github.com"
git push

- name: Comment on PR if binding updates needed
if: ${{ steps.binding-diff.outputs.binding_has_update == 'true' }}
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "⚠️ This submodule update requires manual code generation changes. Please review the changes and update accordingly."
exit 1

- name: Comment on PR if hash updated
if: ${{ steps.update-hash.outputs.hash_updated == 'true' && steps.binding-diff.outputs.binding_has_update != 'true' }}
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "✅ Successfully updated VoicevoxCore commit hash to \`$NEW_HASH\`"