blob: f6ea0bd002b05fd96311c5e72ba6798c2368ee05 [file] [log] [blame] [edit]
# Copyright (C) 2025 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Sync generated proto files
on:
schedule:
# Run every day at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
permissions:
contents: write # Needed to push branch for PR
pull-requests: write # Needed to create PR
jobs:
sync-protos:
runs-on: self-hosted
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main # Always use main branch
fetch-depth: 0
- uses: ./.github/actions/install-build-deps
- name: Setup build directory
run: |
tools/gn gen out/proto_sync --args="is_debug=false"
- name: Generate proto files
run: |
tools/gen_all --protos out/proto_sync
- name: Check for changes
id: check_changes
run: |
# Check if there are any changes in generated proto files
if [ -n "$(git status --porcelain)" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Close existing proto sync PRs
if: steps.check_changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Find and close any existing open PRs from the sync-protos branch
EXISTING_PRS=$(gh pr list --head dev/github-bot/sync-protos --json number --jq '.[].number')
if [ -n "$EXISTING_PRS" ]; then
for PR_NUMBER in $EXISTING_PRS; do
echo "Closing existing PR #$PR_NUMBER"
gh pr close $PR_NUMBER --comment "Closing in favor of a new proto sync PR with updated changes."
done
fi
- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
commit-message: |
Sync generated proto files
This is an automated update of generated proto files (.gen.cc/h,
.pcz.h, descriptors, etc.) to match their .proto definitions.
branch: dev/github-bot/sync-protos
delete-branch: true
title: 'Sync generated proto files'
body: |
This PR automatically synchronizes generated proto files with their `.proto` definitions.
## Generated files updated
- `.gen.cc` and `.gen.h` files
- `.pcz.h` files
- Binary descriptors
- Python proto bindings
This is an automated PR generated by the `sync-protos` workflow.
labels: automated