From b3669e04a5877bee28fc82bd93d27faa8d5b0297 Mon Sep 17 00:00:00 2001 From: Justin Poehnelt Date: Wed, 4 Mar 2026 13:57:20 -0700 Subject: [PATCH] feat: Implement hourly cron and manual trigger for the generate-skills workflow to auto-sync skills via pull requests and downgrade CI drift check to a warning. (#63) * feat: Implement hourly cron and manual trigger for the generate-skills workflow to auto-sync skills via pull requests and downgrade CI drift check to a warning. * chore: regenerate skills [skip ci] --------- Co-authored-by: github-actions[bot] --- .changeset/generate-skills-cron.md | 5 ++ .github/workflows/ci.yml | 3 +- .github/workflows/generate-skills.yml | 67 ++++++++++++++++++++++----- skills/gws-admin/SKILL.md | 2 +- 4 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 .changeset/generate-skills-cron.md diff --git a/.changeset/generate-skills-cron.md b/.changeset/generate-skills-cron.md new file mode 100644 index 0000000..d0bc87b --- /dev/null +++ b/.changeset/generate-skills-cron.md @@ -0,0 +1,5 @@ +--- +"@googleworkspace/cli": patch +--- + +Add hourly cron to generate-skills workflow to auto-sync skills with upstream Google Discovery API changes via PR diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc3d114..89dfcec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,8 +127,7 @@ jobs: - name: Check for drift run: | if ! git diff --exit-code skills/; then - echo "::error::Skills are out of date. Run 'cargo run -- generate-skills' and commit the changes." - exit 1 + echo "::warning::Skills are out of date — the hourly auto-sync PR will fix this automatically." fi coverage: diff --git a/.github/workflows/generate-skills.yml b/.github/workflows/generate-skills.yml index 1678b6a..03f946a 100644 --- a/.github/workflows/generate-skills.yml +++ b/.github/workflows/generate-skills.yml @@ -15,12 +15,15 @@ name: Generate Skills on: + schedule: + - cron: "0 * * * *" # Hourly — keeps skills in sync with Discovery API changes + workflow_dispatch: # Manual trigger push: branches-ignore: - - main # main is kept up to date by PR merges; this bot targets PR branches + - main # main is kept up to date by PR merges concurrency: - group: generate-skills-${{ github.ref }} + group: generate-skills-${{ github.ref_name }} cancel-in-progress: true env: @@ -31,15 +34,14 @@ jobs: name: Generate and commit skills runs-on: ubuntu-latest permissions: - contents: write # needed to push the auto-commit + contents: write + pull-requests: write steps: - uses: actions/checkout@v4 with: - # Check out the PR head branch so we can push back to it. - # For push events on a branch this is already the branch SHA. + # For cron/dispatch: check out main. For push: check out the branch. ref: ${{ github.head_ref || github.ref_name }} - # Use the default GITHUB_TOKEN — it has write access to the same repo. token: ${{ secrets.GITHUB_TOKEN }} - name: Install Rust @@ -56,16 +58,59 @@ jobs: - name: Generate skills run: cargo run -- generate-skills + - name: Check for changes + id: diff + run: | + if git diff --quiet skills/ docs/skills.md; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + # --- Cron / workflow_dispatch: open a PR against main --- + - name: Create changeset for sync PR + if: >- + steps.diff.outputs.changed == 'true' && + (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') + run: | + mkdir -p .changeset + cat > .changeset/sync-skills.md << 'EOF' + --- + "@googleworkspace/cli": patch + --- + + Sync generated skills with latest Google Discovery API specs + EOF + + - name: Create or update sync PR + if: >- + steps.diff.outputs.changed == 'true' && + (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') + uses: peter-evans/create-pull-request@v7 + with: + branch: chore/sync-skills + title: "chore: sync skills with Discovery API" + body: | + Automated PR — the Google Discovery API specs have changed and the + generated skill files are out of date. + + Created by the **Generate Skills** workflow (`generate-skills.yml`). + commit-message: "chore: regenerate skills from Discovery API" + add-paths: | + skills/ + docs/skills.md + .changeset/sync-skills.md + delete-branch: true + + # --- Push events (non-main branches): commit directly --- - name: Commit and push if changed + if: >- + steps.diff.outputs.changed == 'true' && + github.event_name == 'push' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - if git diff --quiet; then - echo "No skill changes — nothing to commit." - exit 0 - fi - git add skills/ docs/skills.md git commit -m "chore: regenerate skills [skip ci]" git push diff --git a/skills/gws-admin/SKILL.md b/skills/gws-admin/SKILL.md index 149fb64..db7ff81 100644 --- a/skills/gws-admin/SKILL.md +++ b/skills/gws-admin/SKILL.md @@ -147,7 +147,7 @@ gws admin [flags] ### users - - `createGuest` — Create a guest user with access to a [subset of Workspace capabilities](https://support.google.com/a/answer/16558545). This feature is currently in Alpha. Please reach out to support if you are intere + - `createGuest` — Create a guest user with access to a [subset of Workspace capabilities](https://support.google.com/a/answer/16558545?hl=en). This feature is currently in Alpha. Please reach out to support if you are - `delete` — Deletes a user. - `get` — Retrieves a user. - `insert` — Creates a user. Mutate calls immediately following user creation might sometimes fail as the user isn't fully created due to propagation delay in our backends. Check the error details for the "User cr