Skip to content

generate

generate #35

Workflow file for this run

on:
workflow_dispatch:
inputs:
services:
required: true
type: string
description: A JSON array of service names. E.g., ["aiplatform"]
workflow_call:
inputs:
services:
required: true
type: string
description: A JSON array of service names. E.g., ["aiplatform"]
name: generate
jobs:
generate_one:
runs-on: 'ubuntu-24.04'
strategy:
fail-fast: false
max-parallel: 4
matrix:
service: ${{fromJson(inputs.services)}}
steps:
- run: echo generating ${{ matrix.service }}
- uses: actions/checkout@v2
with:
fetch-depth: 1
path: google-api-java-client-services
token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
- uses: actions/checkout@v2
with:
repository: googleapis/discovery-artifact-manager
fetch-depth: 1
path: discovery-artifact-manager
- uses: actions/setup-python@v5
with:
python-version: 3.8.18
- run: |
sudo apt update
python3 --version
pip install pip==21.3.1
pip --version
- run: ./google-api-java-client-services/.github/workflows/generate.sh ${{ matrix.service }}
- name: Create PR via Local Checkout (Large Commit Support)
shell: bash
working-directory: google-api-java-client-services
env:
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
SERVICE: ${{ matrix.service }}
AUTHOR: "Cloud Java Bot <cloud-java-bot@google.com>"
BASE_REPO: "${{ github.repository }}"
run: |
set -ex
# 1. Setup Identity
git config user.name "Cloud Java Bot"
git config user.email "cloud-java-bot@google.com"
# 3. Create Branch
BRANCH="regenerate-${SERVICE}"
git checkout -b "$BRANCH"
# 4. Stage specific files (Large commit handling)
TARGET_PATH="clients/google-api-services-${SERVICE}"
git add "$TARGET_PATH"
# 5. Commit & Push
MESSAGE="chore: regenerate ${SERVICE} client"
if git diff-index --quiet HEAD --; then
echo "No changes to commit for ${SERVICE}."
exit 0
fi
git commit -m "$MESSAGE"
git push origin "$BRANCH" --force
gh pr create \
--repo "$BASE_REPO" \
--head "${BRANCH}" \
--base "main" \
--title "$MESSAGE" \
--body "Generated in GitHub action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
|| echo "PR already exists or failed to create, but changes are pushed."