Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
94 changes: 94 additions & 0 deletions .github/workflows/update-playwright-e2e-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2021 Collate
# 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: Update Playwright E2E Documentation
on:
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Validate Branch
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo "This workflow can only be run on the main branch."
exit 1
fi

- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: "openmetadata-ui/src/main/resources/ui/.nvmrc"
cache: "yarn"
cache-dependency-path: openmetadata-ui/src/main/resources/ui/yarn.lock

- name: Install Yarn
run: npm install -g yarn

- name: Install Dependencies
working-directory: openmetadata-ui/src/main/resources/ui
run: yarn install --frozen-lockfile --ignore-scripts

- name: Install Playwright Browsers
working-directory: openmetadata-ui/src/main/resources/ui
run: npx playwright install --with-deps

- name: Generate E2E Docs
working-directory: openmetadata-ui/src/main/resources/ui
run: yarn generate:e2e-docs

- name: Detect Changes
id: git-check
run: |
if [ -z "$(git status --porcelain openmetadata-ui/src/main/resources/ui/playwright/docs)" ]; then
echo "No changes detected."
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected."
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Create Pull Request
if: steps.git-check.outputs.changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH_NAME="chore/update-playwright-docs"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git checkout -B $BRANCH_NAME
git add openmetadata-ui/src/main/resources/ui/playwright/docs
git commit -m "chore: update Playwright E2E documentation"
git push origin $BRANCH_NAME --force

gh pr create \
--title "chore: update Playwright E2E documentation" \
--body "This is an automated PR to update the Playwright E2E documentation. Generated by the \`Update Playwright E2E Documentation\` workflow." \
--base main \
--head $BRANCH_NAME || {
if gh pr list --head $BRANCH_NAME --state open --json number -jq '.[0].number' | grep -q .; then
echo "PR already exists"
else
echo "Failed to create PR"
exit 1
fi
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,24 @@ yarn generate:e2e-docs

## 🔄 Workflow Integration

**⚠️ Note: CI integration is currently Work In Progress.**
Please run the generator manually before pushing changes.

### Manual Generation (Required)
See the [Usage](#-usage) section above.
Run: `yarn generate:e2e-docs`

### GitHub Actions (In Progress)
Defined in `.github/workflows/playwright-docs-check.yml`.
* **Trigger**: Pull Requests to `main`.
* **Action**: Checks if the documentation matches the code.
* **Auto-Fix**: If docs are outdated (e.g., if the pre-commit hook was bypassed), the CI job will:
1. Fail the initial check.
2. Regenerate the documentation.
3. **Automatically commit and push** the fixes to your PR branch.
### Automation
A GitHub Actions workflow is available to automate the documentation update process and ensure the `main` branch always has the latest E2E docs.

* **Workflow Name**: `Update Playwright E2E Documentation`
* **File**: `.github/workflows/update-playwright-e2e-docs.yml`
* **Trigger**: Manual trigger via `workflow_dispatch`.
* **Logic**:
1. Runs against the `main` branch.
2. Installs dependencies using `yarn install --frozen-lockfile`.
3. Executes documentation generation via `yarn generate:e2e-docs`.
4. **Detection**: Uses `git status` to detect if any documentation files were modified.
5. **Auto PR**: If changes are found, it creates/updates the `chore/update-playwright-docs` branch and automatically opens a Pull Request to `main`.

### Manual Generation
You can still run the generator manually in your local environment before pushing:
```bash
yarn generate:e2e-docs
```

## 🏷️ Classification & Tagging Guide

Expand Down
Loading