# 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: jobs: update-docs: runs-on: ubuntu-latest permissions: contents: write pull-requests: write 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: corepack enable - 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 chromium --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 }