diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 2ff44466cf2..00000000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: NPM install and build - -on: - workflow_call: - inputs: - cache_sha: - type: string - required: true - -jobs: - install-build: - name: Install and build - runs-on: ubuntu-latest - steps: - - name: Check if contributor is an org member - id: is_organization_member - if: github.event_name == 'pull_request_target' - uses: JamesSingleton/is-organization-member@1.0.1 - with: - organization: ramp4-pcar4 - username: ${{ github.event.pull_request.head.user.login }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Output comment and end build if not org member - if: github.event_name == 'pull_request_target' - run: | - result=${{ steps.is_organization_member.outputs.result }} - if [ $result == false ]; then - user=${{ github.event.pull_request.head.user.login }} - echo Either ${user} is not part of the ramp4-pcar4 organization - echo or ${user} has its Organization Visibility set to Private at - echo https://github.com/orgs/ramp4-pcar4/people?query=${user} - exit 1 - fi - - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref_name }} - repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - - - uses: actions/setup-node@v4 - with: - node-version: '22.5.1' - cache: 'npm' - - - name: Try to restore node_modules folder from cache - id: cache-node-modules - uses: actions/cache@v4 - with: - path: ./node_modules - key: npm-${{ hashFiles('./package-lock.json') }} - - - name: Otherwise install npm dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: npm ci - - - name: Persist docsite output for other workflows - uses: actions/cache@v4 - with: - path: 'docs' - key: docs-${{ inputs.cache_sha }} - - - name: Update docsite version references - uses: jacobtomlinson/gha-find-replace@v3 - with: - find: '{{ramp-version}}' - replace: ${{ github.ref_name }} - include: 'docs/**' - regex: false - - - name: Build the ts docs! - run: npm run ts-docs:generate - - - name: Build the vitepress docs! - run: npm run vite-docs:generate - - - name: Consolidate docsite files - run: | - mkdir -p docs - rm -rf docs - mkdir -p docs/api-tech-docs - mv vite-docs/* docs/ - mv ts-docs/* docs/api-tech-docs diff --git a/.github/workflows/demo-build.yml b/.github/workflows/demo-build.yml index f55653803b5..0a7c9df4538 100644 --- a/.github/workflows/demo-build.yml +++ b/.github/workflows/demo-build.yml @@ -60,13 +60,11 @@ jobs: # Create a subfolder and checkout demo-page's content mkdir -p demo-folder/$BRANCH_OR_TAG_NAME/docs - git --work-tree=demo-folder checkout demo-page -- . + git --work-tree=demo-folder checkout demo-page -- . || true # Modify and commit changes npm ci npm run build - npm run ts-docs:generate - npm run vite-docs:generate - name: Publish to NPM if: github.repository == 'ramp4-pcar4/ramp4-pcar4' && startsWith(github.ref, 'refs/tags/v') @@ -81,6 +79,14 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Update docsite version references + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: '{{ramp-version}}' + replace: ${{ github.ref_name }} + include: 'docs/**' + regex: false + - name: Build or delete the demo run: | BRANCH_OR_TAG_NAME=${GITHUB_REF#refs/heads/} @@ -89,6 +95,9 @@ jobs: # Remove the existing demo if it exists rm -rf demo-folder/$BRANCH_OR_TAG_NAME || true + npm run ts-docs:generate + npm run vite-docs:generate + # Move the built files and docs into the demo-folder mv dist demo-folder/$BRANCH_OR_TAG_NAME mv vite-docs demo-folder/$BRANCH_OR_TAG_NAME/docs @@ -106,14 +115,6 @@ jobs: mv demo-folder/* . rmdir demo-folder - - name: Update docsite version references - uses: jacobtomlinson/gha-find-replace@v3 - with: - find: '{{ramp-version}}' - replace: ${{ github.ref_name }} - include: '$BRANCH_OR_TAG_NAME/docs/**' - regex: false - - name: Consolidate docsite files run: | git add . diff --git a/.github/workflows/demo-pr-links.yml b/.github/workflows/demo-pr-links.yml new file mode 100644 index 00000000000..357bae50a22 --- /dev/null +++ b/.github/workflows/demo-pr-links.yml @@ -0,0 +1,26 @@ +name: PR Commenter + +on: + pull_request: + types: [opened] + +jobs: + comment-on-pr: + runs-on: ubuntu-latest + steps: + - name: Comment on the PR + uses: peter-evans/create-or-update-comment@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Your demo site is ready! 🚀 + + Enhanced Testing: + Samples: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-samples.html + Catalogue: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-all.html + + Legacy Testing: + Main: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/ + Catalogue: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-all.html + Samples: https://${{github.event.pull_request.user.login}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-samples.html diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 69d8e699a65..00000000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Publish to GitHub pages and NPM - -on: - workflow_call: - inputs: - cache_sha: - type: string - required: true - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: '22.5.1' - cache: 'npm' - registry-url: 'https://registry.npmjs.org' - - - name: Get dist files - uses: actions/cache@v4 - with: - path: dist - key: dist-${{ inputs.cache_sha }} - - - name: Get docsite files - id: get-docs-cache - uses: actions/cache@v4 - with: - path: docs - key: docs-${{ inputs.cache_sha }} - - - name: Add docs folder to dist - if: steps.get-docs-cache.outputs.cache-hit == 'true' - run: mv docs dist - - - name: Deploy to GitHub Pages 🚀 - uses: JamesIves/github-pages-deploy-action@v4.5.0 - with: - branch: gh-pages - folder: dist - target-folder: ${{ github.head_ref || github.ref_name }} - single-commit: true - - - name: Publish to NPM - if: github.repository == 'ramp4-pcar4/ramp4-pcar4' && startsWith(github.ref, 'refs/tags/v') - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/v} - PACKAGE_VERSION=$(node -p "require('./package.json').version") - if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then - npm version --allow-same-version --no-git-tag-version $TAG_VERSION - fi - - npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - uses: actions/github-script@v6 - name: Post link to demo for PR's - if: github.event_name == 'pull_request_target' && github.event.action == 'opened' - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Your demo site is ready! 🚀 - - Enhanced Testing: - Samples: https://${{github.repository_owner}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-samples.html - Catalogue: https://${{github.repository_owner}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/enhanced-all.html - - Legacy Testing: - Main: https://${{github.repository_owner}}.github.io/ramp4-pcar4/${{github.head_ref}}/ - Catalogue: https://${{github.repository_owner}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-all.html - Samples: https://${{github.repository_owner}}.github.io/ramp4-pcar4/${{github.head_ref}}/demos/index-samples.html` - }) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index ad46e9f462e..00000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Main Build Workflow - -on: - pull_request_target: - types: [opened, synchronize, reopened] - - push: - branches: - - 'main' - - 'qa' - tags: - - v** - -jobs: - docs: - name: Create documentation - if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') - uses: ./.github/workflows/build-docs.yml - with: - cache_sha: ${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} - - build: - name: Build the project - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref_name }} - repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - - - uses: actions/setup-node@v4 - with: - node-version: '22.5.1' - cache: 'npm' - - - name: Try to restore node_modules folder from cache - id: cache-node-modules - uses: actions/cache@v4 - with: - path: ./node_modules - key: npm-${{ hashFiles('./package-lock.json') }} - - - name: Otherwise install npm dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: npm ci - - - name: Update package.json version if necessary - if: startsWith(github.ref, 'refs/tags/v') - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/v} - PACKAGE_VERSION=$(node -p "require('./package.json').version") - if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then - npm version --allow-same-version --no-git-tag-version $TAG_VERSION - echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION." - else - echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)." - fi - - - name: Build the files! - run: npm run build - env: - NODE_OPTIONS: '--max-old-space-size=8192' - - - name: Cache dist files - uses: actions/cache@v4 - with: - path: dist - key: dist-${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} - - deploy-pages: - needs: [docs, build] - if: ${{ always() && needs.build.result == 'success' }} - name: Deploy the files - uses: ./.github/workflows/deploy.yml - with: - cache_sha: ${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} - secrets: inherit