diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5d8728bb03bb..e29aaa2358fc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,6 +9,8 @@ on: env: HAS_SECRETS: ${{ secrets.HAS_SECRETS }} + MAIN_BRANCH: master + CI: true jobs: not-failed-backport: @@ -26,8 +28,6 @@ jobs: if: "!startsWith(github.event.head_commit.message, '[skip ci] ')" env: - MAIN_BRANCH: master - CI: true PATH: /bin:/usr/bin:/usr/local/bin:/home/runner/.local/bin steps: @@ -121,16 +121,12 @@ jobs: - run: make transifex-send if: env.HAS_SECRETS == 'HAS_SECRETS' && github.ref == format('refs/heads/{0}', env.MAIN_BRANCH) - - run: buildtools/publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: env.HAS_SECRETS == 'HAS_SECRETS' - run: buildtools/npm-publish if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'push' - name: Publish Storybook to Chromatic to run visual tests run: npm run chromatic -- --project-token=$(gopass show gs/ci/chromatic/ngeo_token) - if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name != 'pull_request_target' + if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'push' - name: Publish Storybook to Chromatic to run visual tests run: GITHUB_SHA=${GITHUB_SHA_} npm run chromatic -- --project-token=$(gopass show gs/ci/chromatic/ngeo_token) --branch-name=${GITHUB_HEAD_REF} if: env.HAS_SECRETS == 'HAS_SECRETS' && github.event_name == 'pull_request_target' @@ -147,3 +143,51 @@ jobs: if: > github.ref == format('refs/heads/{0}', env.MAIN_BRANCH) && env.HAS_SECRETS == 'HAS_SECRETS' + + - name: Prepare gh-pages + run: | + mkdir -p gh-pages + cp -ar api/dist gh-pages/api + cp -ar apidoc gh-pages/apidoc + cp -ar .build/examples-hosted gh-pages/examples + cp -ar .build/storybook gh-pages/storybook + if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/') && env.HAS_SECRETS == 'HAS_SECRETS' + + - uses: actions/upload-artifact@v2 + with: + name: gh-pages + path: gh-pages + if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/') && env.HAS_SECRETS == 'HAS_SECRETS' + + gh-pages: + runs-on: ubuntu-20.04 + name: Github Pages + timeout-minutes: 10 + if: startsWith(github.ref, 'refs/heads/') && ! contains(github.ref_name, '/') + concurrency: gh-pages + needs: + - main + + steps: + - uses: actions/checkout@v2 + with: + ref: gh-pages + fetch-depth: 0 + if: env.HAS_SECRETS == 'HAS_SECRETS' + + - uses: actions/download-artifact@v2 + with: + name: gh-pages + path: ${{ github.ref_name }} + if: env.HAS_SECRETS == 'HAS_SECRETS' + + - name: Rewrite root commit and force push + run: | + git config --global user.name "Continuous integration" + git config --global user.email "ci@comptocamp.org" + FIRST_COMMIT=$(git log --format='%H' | tail -1) + git reset --quiet --mixed $FIRST_COMMIT + git add ${{ github.ref_name }} + git commit --quiet --amend --message="Update GitHub pages" + git push --force + if: env.HAS_SECRETS == 'HAS_SECRETS' diff --git a/.github/workflows/test_url.yaml b/.github/workflows/test_url.yaml index ef769682a9a8..52baa9b17717 100644 --- a/.github/workflows/test_url.yaml +++ b/.github/workflows/test_url.yaml @@ -30,6 +30,7 @@ jobs: body: [ \`Examples: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/examples/\`, \`Storybook: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/storybook/\`, + \`API help: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/api/apihelp/apihelp.html\`, \`API documentation: https://camptocamp.github.io/ngeo/\${process.env.GITHUB_HEAD_REF}/apidoc/\`, ].join('\n'), event: 'COMMENT' diff --git a/buildtools/publish b/buildtools/publish deleted file mode 100755 index 606d9e6b8f7c..000000000000 --- a/buildtools/publish +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -ex - -# The MIT License (MIT) -# -# Copyright (c) Camptocamp SA -# -# Permission is hereby granted, free of charge, to any person obtaining a copy of -# this software and associated documentation files (the "Software"), to deal in -# the Software without restriction, including without limitation the rights to -# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -# the Software, and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -GIT_REF=$(git rev-parse HEAD) - -if [ -z "${GITHUB_REF}" ] -then - GIT_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD) -elif [[ "${GITHUB_REF}" =~ ^refs/heads/.* ]] -then - GIT_BRANCH=$(echo "${GITHUB_REF}"|sed 's|^refs/heads/||g') -else - echo "Build is not on a branch" - exit -fi - -if [[ ${GIT_BRANCH} =~ "/" ]] -then - echo "Skipping deploy of external branch ${GIT_BRANCH}" - exit -fi - -cp -r api/dist api/dist_ - -# Cloning gh-pages into a local temporary directory -git fetch origin -git checkout -b gh-pages origin/gh-pages - -git rm --ignore-unmatch -r --quiet --force ${GIT_BRANCH} || true - -mkdir -p ${GIT_BRANCH}/examples -cp -r .build/examples-hosted/* ${GIT_BRANCH}/examples/ -cp -r .build/storybook ${GIT_BRANCH}/ -mv apidoc ${GIT_BRANCH}/ -mv api/dist_ ${GIT_BRANCH}/api - -# Rewrite root commit and force push -FIRST_COMMIT=$(git log --format='%H' | tail -1) -git reset --quiet --mixed $FIRST_COMMIT -git add ${GIT_BRANCH} -git commit --quiet --amend --message="Update GitHub pages" - -remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/camptocamp/ngeo.git" -git push "${remote_repo}" gh-pages --force - -git checkout ${GIT_REF} diff --git a/buildtools/webpack.api.js b/buildtools/webpack.api.js index dd5516d31f9e..9403ccea6fc4 100644 --- a/buildtools/webpack.api.js +++ b/buildtools/webpack.api.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2018-2021 Camptocamp SA +// Copyright (c) 2018-2022 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -47,6 +47,7 @@ module.exports = (env, argv) => { rules: [ { test: /\.js$/, + exclude: [/(core-js|strip-ansi)/], use: { loader: 'babel-loader', options: { @@ -61,6 +62,7 @@ module.exports = (env, argv) => { output: { filename: 'api.js', path: dest, + libraryTarget: 'umd', libraryExport: 'default', library: library, },