(#4993) Accordion No Nesting Headers #8842
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Workflow | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| - develop | |
| - 'hotfix/**' | |
| - 'release/**' | |
| - 'feature/**' | |
| - 'prototype/**' | |
| tags: | |
| - '*' | |
| pull_request: | |
| jobs: | |
| build: | |
| name: Build, Test and Upload Artifacts | |
| runs-on: ubuntu-22.04 | |
| services: | |
| apache: | |
| image: httpd:2.4 | |
| ports: | |
| - 8080:80 | |
| steps: | |
| ## Setup variables for build info | |
| - name: Set Variables | |
| id: set_vars | |
| run: | | |
| ## PUSH | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| BUILD_NAME=$(sed -E 's/refs\/(heads|tags)\///; s/\//__/g;' <<< $GITHUB_REF) | |
| BRANCH_NAME=$(sed -E 's/refs\/(heads|tags)\///;' <<< $GITHUB_REF) | |
| COMMIT_HASH=$(echo "${GITHUB_SHA}") | |
| ## PULL_REQUEST | |
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
| BUILD_NAME=$(echo "pr-${{ github.event.pull_request.number }}") | |
| BRANCH_NAME=$(echo "pr-${{ github.event.pull_request.number }}") | |
| COMMIT_HASH=$(echo "${{ github.event.pull_request.head.sha }}") | |
| else | |
| ## ERROR | |
| exit 1 | |
| fi | |
| ## For step checks and artifact deployment path. | |
| ## Same for push and PR | |
| export REPO_FULL=${{ github.repository }} | |
| export REPO_RE='([^/]+)/(.*)' | |
| [[ "$REPO_FULL" =~ $REPO_RE ]] | |
| REPO_OWNER=$(echo "${BASH_REMATCH[1]}") | |
| REPO_NAME=$(echo "${BASH_REMATCH[2]}") | |
| ## Set step outputs for later use | |
| echo "build_name=${BUILD_NAME}" >> $GITHUB_OUTPUT | |
| echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
| echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT | |
| echo "repo_owner=${REPO_OWNER}" >> $GITHUB_OUTPUT | |
| echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT | |
| - name: Add Comment on Where to Test | |
| uses: actions/github-script@v6 | |
| if: startsWith(github.repository, 'NCIOCPL') && github.event_name == 'pull_request' && github.event.action == 'opened' | |
| env: | |
| BUILD_NAME: ${{steps.set_vars.outputs.build_name}} | |
| with: | |
| github-token: ${{secrets.GITHUB_TOKEN}} | |
| ## NOTE: The script below is JavaScript | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: ` | |
| ## Viewing Information | |
| * [The documentation site](https://designsystem-dev.cancer.gov/${ process.env.BUILD_NAME }/) | |
| * [NCIDS JS Documentation](https://designsystem-dev.cancer.gov/${ process.env.BUILD_NAME }/ncids-js/) | |
| * [The storybook site](https://designsystem-dev.cancer.gov/${ process.env.BUILD_NAME }/storybook/) | |
| * [The example site](https://designsystem-dev.cancer.gov/${ process.env.BUILD_NAME }/example-site/) | |
| ` | |
| }) | |
| ## This clones and checks out. | |
| - name: Checkout branch | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| ## Setup node and npm caching. | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| registry-url: https://npm.pkg.github.com | |
| scope: '@nciocpl' | |
| ## Install Packages | |
| - name: Install packages | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| CI: true | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ## Lint the code | |
| - name: Run Lint | |
| run: pnpm run lint | |
| env: | |
| CI: true | |
| ## Download twigcs docker image | |
| - name: Setup twigcs | |
| run: docker pull --quiet ghcr.io/nciocpl/twigcs-docker:v1.0.1 > /dev/null 2>&1 | |
| env: | |
| CI: true | |
| ## Lint the twig | |
| - name: Run twig code sniffer | |
| run: pnpm run test:twig | |
| env: | |
| CI: true | |
| ## Now test the code | |
| - name: Run Tests | |
| run: pnpm run test | |
| env: | |
| CI: true | |
| ## Build all the things for publishing. This is a proxy for testing. | |
| - name: Build Doc Site | |
| run: pnpm run docs-artifact | |
| env: | |
| CI: true | |
| ## This is used by Gatsby and NEEDs to be the path that will ultimately | |
| ## be in netstorage for designsystem-dev. NOTE: this should not get | |
| ## set for production builds. | |
| DOCS_PREFIX_PATH: ${{ format('/{0}', steps.set_vars.outputs.build_name) }} | |
| ## This is used by Storybook and NEEDs to be the path that will ultimately | |
| ## be in netstorage for designsystem-dev. NOTE: this should **still** get | |
| ## set for production builds, but without the build_name. | |
| STORYBOOK_BASE_HREF: ${{ format('/{0}/storybook', steps.set_vars.outputs.build_name) }} | |
| ## This is used by the example site and NEEDs to be the path that will ultimately | |
| ## be in netstorage for designsystem-dev. NOTE: this should **still** get | |
| ## set for production builds, but without the build_name. | |
| EXAMPLE_SITE_PUBLIC_PATH: ${{ format('/{0}/example-site', steps.set_vars.outputs.build_name) }} | |
| ## This is used by the SitewideSearchApp and NEEDs to be the path that will ultimately | |
| ## be in netstorage for designsystem-dev. NOTE: this should **still** get | |
| ## set for production builds, but without the build_name. | |
| SITE_DOMAIN: "designsystem-dev.cancer.gov" | |
| ## Generate build-info.json to house information about this specific build. | |
| ## Used for product test deployment | |
| - name: Create Build Information | |
| env: | |
| BUILD_INFO: ${{ toJson(steps.set_vars.outputs) }} | |
| run: | | |
| echo $BUILD_INFO | |
| echo $BUILD_INFO > ./dist/documentation-site/build-info.json | |
| ## Put the built site on to apache for testing. | |
| - name: Copy built storybook to apache | |
| working-directory: ./dist/documentation-site | |
| run: | | |
| CONTAINER_ID=$(docker ps -q --filter "ancestor=httpd:2.4") | |
| # Make the branch/tag/pr directory. | |
| docker exec $CONTAINER_ID mkdir "/usr/local/apache2/htdocs/${{steps.set_vars.outputs.build_name}}" | |
| docker cp . "$CONTAINER_ID:/usr/local/apache2/htdocs/${{steps.set_vars.outputs.build_name}}" | |
| ## Test a11y | |
| - name: Run accessibility tests | |
| working-directory: ./testing/ncids-js-testing | |
| run: pnpm run test-pa11y | |
| env: | |
| CI: true | |
| PA11Y_BASE_URL: ${{ format('http://localhost:8080/{0}/example-site/', steps.set_vars.outputs.build_name) }} | |
| ## Now test the css | |
| - name: Run css tests | |
| working-directory: ./testing/ncids-css-testing | |
| run: pnpm backstop test --config='backstop.config.cjs' --docker | |
| env: | |
| CI: true | |
| BACKSTOP_BASE_URL: ${{ format('http://localhost:8080/{0}/storybook/', steps.set_vars.outputs.build_name) }} | |
| ## Upload failed css tests | |
| - uses: actions/upload-artifact@v4 | |
| name: Upload failed tests | |
| if: failure() | |
| with: | |
| name: failed-backstopjs | |
| path: /home/runner/work/ncids/ncids/testing/ncids-css-testing/.backstop/ | |
| include-hidden-files: true | |
| ## Upload successful css tests | |
| - uses: actions/upload-artifact@v4 | |
| name: Upload successful tests | |
| with: | |
| name: success-backstopjs | |
| path: /home/runner/work/ncids/ncids/testing/ncids-css-testing/.backstop/test/**/report.json | |
| include-hidden-files: true | |
| ## TODO: Upload the test results artifact | |
| # - name: Archive production artifacts | |
| # uses: actions/upload-artifact@v1 | |
| # with: | |
| # name: test-results | |
| # path: coverage | |
| ## Upload the test results artifact | |
| - name: Archive production artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: documentation-site | |
| path: dist/documentation-site/ | |
| include-hidden-files: true | |
| deploy-doc-site: | |
| name: Deploy documentation site to dev server | |
| ## Only do this if the repo is NCIOCPL | |
| if: startsWith(github.repository, 'NCIOCPL') | |
| ## This job depends on build completing | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download built site | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: documentation-site | |
| path: documentation-site | |
| ## Setup vars from Build Info from build job | |
| - name: Setup Job env | |
| run: | | |
| ## Set Vars | |
| BUILD_NAME=$(jq -r '.build_name' < ./documentation-site/build-info.json) | |
| BRANCH_NAME=$(jq -r '.branch_name' < ./documentation-site/build-info.json) | |
| COMMIT_HASH=$(jq -r '.commit_hash' < ./documentation-site/build-info.json) | |
| REPO_OWNER=$(jq -r '.repo_owner' < ./documentation-site/build-info.json) | |
| REPO_NAME=$(jq -r '.repo_name' < ./documentation-site/build-info.json) | |
| ## Set Action Env | |
| echo "BUILD_NAME=${BUILD_NAME}" >> $GITHUB_ENV | |
| echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | |
| echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV | |
| echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_ENV | |
| echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV | |
| ######## ERROR IF PR FROM FORK | |
| if [ "$REPO_OWNER" != "NCIOCPL" ]; then | |
| echo "YOU SHOULD NOT SEND PR FROM FORK!!!" | |
| exit 1 | |
| fi | |
| ## We need to create the zip for netstorage | |
| - name: Zip documentation site | |
| run: | | |
| pushd documentation-site | |
| zip -r ../${BUILD_NAME}.zip * | |
| popd | |
| - name: Upload artifact to netstorage | |
| uses: nciocpl/[email protected] | |
| with: | |
| hostname: ${{ secrets.ns_hostname }} | |
| cp-code: ${{ secrets.ns_cpcode }} | |
| key-name: ${{ secrets.ns_keyname }} | |
| key: ${{ secrets.ns_key }} | |
| index-zip: true | |
| local-path: ${{ format('{0}.zip', env.BUILD_NAME) }} | |
| ## Note this action automatically prepends the cpcode to the path. | |
| destination-path: ${{ format('/{0}.zip', env.BUILD_NAME) }} | |
| - name: Clear Site Cache | |
| uses: nciocpl/[email protected] | |
| with: | |
| hostname: ${{ secrets.eg_hostname }} | |
| client-token: ${{ secrets.eg_client_token }} | |
| client-secret: ${{ secrets.eg_client_secret }} | |
| access-token: ${{ secrets.eg_access_token }} | |
| type: "cpcodes" | |
| ref: ${{ format('{0},{1}', secrets.ns_cpcode, secrets.prop_cpcode) }} |