diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml new file mode 100644 index 00000000..7725a81b --- /dev/null +++ b/.github/workflows/build-and-run-tests.yml @@ -0,0 +1,45 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node. +# This workflow will be run whenever a new commit is pushed or when a PR is opened up. +# Guide: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Build and Run Tests + +on: + # run this for every push (CI) + push: + # also run this for PR + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + # run this job for every combination of given matrix variables + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + + steps: + + # checkout our repo for the current commit + - name: Check out repo + uses: actions/checkout@v3 + + # setup specified node version + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile # do a clean install of all of our dependencies + + # build our library to catch any build errors + - name: Build! + run: yarn run build-dist + + # run all of our tests + - name: Test! + run: yarn test diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml new file mode 100644 index 00000000..c8d721a3 --- /dev/null +++ b/.github/workflows/deploy-gh-pages.yml @@ -0,0 +1,81 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and site, and run the deploy script. +# The deploy script will publish the build to gh-pages. +# This workflow will be run whenever a new release is published. + +# NOTE (pradeep): I'm having this workflow bail out if the release doesn't target v1.2.x. +# This is because we don't have a way (yet) to support multiple FDT versions/docs be deployed at the same time, +# and hence we choose to deploy only the most stable release. + +# Guide: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Deploy to gh-pages + +on: + release: + types: [published] + +jobs: + + check-release: + name: Check if release is stable + runs-on: ubuntu-latest + + # map step output to job output + outputs: + is_stable: ${{ steps.check-release-stable.outputs.is_stable }} + + steps: + - name: Check if release is stable + id: check-release-stable + env: + # Store the tag name of the release in `RELEASE_TAG` (eg: v1.0.10) + RELEASE_TAG: ${{ github.event.release.tag_name }} + + # Check if the release tag name is a stable candidate for deployment + # NOTE (pradeep): Only allow 1.2.x versions to be deployed right now + run: | + echo "RELEASE_TAG is: " $RELEASE_TAG + if [[ $RELEASE_TAG =~ ^v1\.2\.[0-9]+$ ]]; + then + echo "This is a stable release!" + echo "::set-output name=is_stable::true" + else + echo "This is not a stable release!" + echo "::set-output name=is_stable::false" + fi + + + deploy: + name: Deploy website via gh-pages! + needs: check-release + runs-on: ubuntu-latest + + # skip deploying to gh-pages if release is not "stable" + if: ${{ needs.check-release.outputs.is_stable == 'true' }} + + steps: + + # checkout our repo for the current commit + - name: Check out repo + uses: actions/checkout@v3 + + # setup node version 16 which is not old but still stable + - name: Use Node.js 16 + uses: actions/setup-node@v3 + with: + node-version: 16 + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile # do a clean install of all of our dependencies + + # build our static contents + - name: Build static site! + run: yarn run site-build + + # publish our site to gh-pages + - name: Deploy to gh-pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} # authenticate the action to our workflow + publish_dir: ./__site__ # this directory will be copied over to gh-pages diff --git a/package.json b/package.json index e54d75ab..982175fb 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "bugs": { "url": "https://github.com/schrodinger/fixed-data-table-2/issues" }, - "homepage": "http://schrodinger.github.io/fixed-data-table-2", + "homepage": "https://schrodinger.github.io/fixed-data-table-2", "tags": [ "react", "table"