|
| 1 | +# Copyright 2021 Collate |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# Unless required by applicable law or agreed to in writing, software |
| 7 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 8 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 9 | +# See the License for the specific language governing permissions and |
| 10 | +# limitations under the License. |
| 11 | + |
| 12 | +name: Update Playwright E2E Documentation |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + update-docs: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + steps: |
| 23 | + - name: Validate Branch |
| 24 | + run: | |
| 25 | + if [ "${{ github.ref }}" != "refs/heads/main" ]; then |
| 26 | + echo "This workflow can only be run on the main branch." |
| 27 | + exit 1 |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Checkout Repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version-file: "openmetadata-ui/src/main/resources/ui/.nvmrc" |
| 39 | + cache: "yarn" |
| 40 | + cache-dependency-path: openmetadata-ui/src/main/resources/ui/yarn.lock |
| 41 | + |
| 42 | + - name: Install Yarn |
| 43 | + run: npm install -g yarn |
| 44 | + |
| 45 | + - name: Install Dependencies |
| 46 | + working-directory: openmetadata-ui/src/main/resources/ui |
| 47 | + run: yarn install --frozen-lockfile --ignore-scripts |
| 48 | + |
| 49 | + - name: Install Playwright Browsers |
| 50 | + working-directory: openmetadata-ui/src/main/resources/ui |
| 51 | + run: npx playwright install --with-deps |
| 52 | + |
| 53 | + - name: Generate E2E Docs |
| 54 | + working-directory: openmetadata-ui/src/main/resources/ui |
| 55 | + run: yarn generate:e2e-docs |
| 56 | + |
| 57 | + - name: Detect Changes |
| 58 | + id: git-check |
| 59 | + run: | |
| 60 | + if [ -z "$(git status --porcelain openmetadata-ui/src/main/resources/ui/playwright/docs)" ]; then |
| 61 | + echo "No changes detected." |
| 62 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 63 | + else |
| 64 | + echo "Changes detected." |
| 65 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Create Pull Request |
| 69 | + if: steps.git-check.outputs.changed == 'true' |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + run: | |
| 73 | + BRANCH_NAME="chore/update-playwright-docs" |
| 74 | + git config user.name "github-actions[bot]" |
| 75 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 76 | +
|
| 77 | + git checkout -B $BRANCH_NAME |
| 78 | + git add openmetadata-ui/src/main/resources/ui/playwright/docs |
| 79 | + git commit -m "chore: update Playwright E2E documentation" |
| 80 | + git push origin $BRANCH_NAME --force |
| 81 | +
|
| 82 | + gh pr create \ |
| 83 | + --title "chore: update Playwright E2E documentation" \ |
| 84 | + --body "This is an automated PR to update the Playwright E2E documentation. Generated by the \`Update Playwright E2E Documentation\` workflow." \ |
| 85 | + --base main \ |
| 86 | + --head $BRANCH_NAME || { |
| 87 | + if gh pr list --head $BRANCH_NAME --state open --json number -jq '.[0].number' | grep -q .; then |
| 88 | + echo "PR already exists" |
| 89 | + else |
| 90 | + echo "Failed to create PR" |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | + } |
0 commit comments