From f2f5ff68dd40ed97681474ba10b7603712f7ca74 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Wed, 14 Apr 2021 18:17:28 +0200 Subject: [PATCH] Apply geOrchestra customizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit relying on nx cache for building docker image disable nx-cloud feat:Β include georchestra header df: support ENV for settings df: set base href to ./ chore: build docker image datafeeder - Adding a gh action to build / publish a docker image gh-action - fixing georchestra version (docker tag) chore: lint chore: add thesaurus url to settings base-ref=/impot/' nginx - redirect onto the index.html when a UUID is present in the URL Used the following in order to write the rule: https://github.com/georchestra/geonetwork-ui/blob/georchestra/apps/datafeeder/src/app/app-routing.module.ts Note: * Not completely tested at runtime, compilation / docker image OK, the rewrite rule has been tested in a running docker image though. * There is still probably some code missing JS-side to manage these query string after the '#' char, as reloading the page after having uploaded a dataset does not reload the app at the exact same place. Concerns: This might break the usage of the docker image outside of the official georchestra docker composition, as the redirection needs the X-forwarded-* headers in order to work properly. github-actions - deactivate gh-pages related actions nginx - no redirect, just serve the index.html npm run format:fix fixing serving virtual routes for the JS app somehow nginx will return a document with an "application/octet-stream" content-type, because it probably can't figure out the type by itself. Forcing "text/html" to be returned, so that the page is not "downloaded" by the browser, but interpreted as a web page. Tests: hacking the nginx configuration using the georchestra docker composition. I was able to reload the page at the expected step once a dataset has been uploaded. chore: set proxy config for DF in georchestra chore: use node 14 in docker image change branch name in gh action change branch name from datafeeder to georchestra-datafeeder build(fix): fix dockerignore for datafeeder build build(fix): raise build job timeout and formating fixing lang calculation some browsers seem to use the "xy-ZT" format for locates, which obviously won't work as lookup key, as a two-char code is expected. tests: runtime tested implement & fix gh action to produce a docker image for the df frontend See https://github.com/georchestra/georchestra/issues/3659 Also fixes the existing action, as the branch has been renamed. fix(nx): change defaultBase to georchestra-datafeeder branch chore: add more to docker ignore feat(docker): run postinstall scripts manually This is required for Nx to build its dependency graph, and then to resolve the result of `createGlobPatternsForDependencies` in the tailwind config feat(header): make df header iframe configurable moving it from index.html to app.component fix: formatting --- .github/workflows/artifacts.yml | 106 ----------- .github/workflows/checks.yml | 165 ------------------ .github/workflows/cleanup.yml | 46 ----- .github/workflows/datafeeder.yaml | 46 +++++ .github/workflows/deploy.yml | 107 ------------ .github/workflows/snyk-security.yml | 51 ------ .github/workflows/webcomponents.yml | 65 ------- Dockerfile | 8 + apps/datafeeder/project.json | 4 +- apps/datafeeder/src/app/app.component.html | 6 + apps/datafeeder/src/app/app.component.spec.ts | 33 ++-- apps/datafeeder/src/app/app.component.ts | 3 + apps/datafeeder/src/app/app.module.ts | 2 + apps/datafeeder/src/index.html | 8 +- apps/datafeeder/src/settings.ts | 2 + nginx-default.conf | 14 ++ nx.json | 4 +- proxy-config.js | 5 +- 18 files changed, 112 insertions(+), 563 deletions(-) delete mode 100644 .github/workflows/artifacts.yml delete mode 100644 .github/workflows/checks.yml delete mode 100644 .github/workflows/cleanup.yml create mode 100644 .github/workflows/datafeeder.yaml delete mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/snyk-security.yml delete mode 100644 .github/workflows/webcomponents.yml create mode 100644 Dockerfile create mode 100644 nginx-default.conf diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml deleted file mode 100644 index e3aea3a031..0000000000 --- a/.github/workflows/artifacts.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Artifacts -run-name: πŸ“¦ Generate artifacts for ${{ github.event_name == 'issue_comment' && 'PR' || (github.event_name == 'release' && '🏷' || '🌱') }} ${{github.event_name == 'issue_comment' && github.event.issue.number || github.ref_name}} - -# This workflow runs whenever the "build affected docker images" checkbox is checked (for PR) -# and also whenever a commit is pushed on main or a tag is pushed -on: - push: - branches: - - main - release: - types: [published] - issue_comment: - types: - - edited - -concurrency: - group: artifacts-${{ github.ref }} - cancel-in-progress: true - -env: - NODE_VERSION: 18.16.1 - # a list of apps to build and publish on releases - APP_NAMES: datafeeder,datahub,metadata-editor - -jobs: - checks: - if: github.event_name != 'issue_comment' || github.event.issue.pull_request - name: Check whether a deploy was requested on a PR - runs-on: ubuntu-latest - outputs: - shouldRun: ${{ github.event_name != 'issue_comment' || (contains(github.event.changes.body.from, '- [ ] πŸ“¦ Build and push affected docker images') && contains(github.event.comment.body, '- [x] πŸ“¦ Build and push affected docker images')) || '' }} - ref: ${{ github.event_name == 'issue_comment' && steps.comment-branch.outputs.head_ref || '' }} - - steps: - - uses: xt0rted/pull-request-comment-branch@v1 - if: github.event_name == 'issue_comment' - id: comment-branch - - build-archive-docker: - needs: checks - if: github.event_name != 'issue_comment' || needs.checks.outputs.shouldRun - name: Build docker images and archives - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ needs.checks.outputs.ref }} # use the PR head ref if applicable; otherwise keep default behaviour - persist-credentials: false - fetch-depth: 0 - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' - - - name: Install dependencies - run: npm ci - - - name: Build all applications and produce archives - if: github.event_name == 'release' - run: | - npx nx run-many --projects=${{ env.APP_NAMES }} --target=build - tools/make-archive.sh ${{env.APP_NAMES}} - - - name: Upload archives to release - if: github.event_name == 'release' - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: dist/archives/* - file_glob: true - tag: ${{ github.ref }} - overwrite: true - - - name: Build all docker images - if: github.event_name == 'release' - run: npx nx run-many --projects=${{ env.APP_NAMES }} --target=docker-build - - - name: Build affected docker images - if: github.event_name != 'release' - # FIXME: excluding data-platform until it has a remote registry to be pushed - run: npx nx affected --target=docker-build --exclude=data-platform - - - name: Tag all docker images on main also as latest - if: github.event_name == 'push' # only happens when pushing on the main branch - run: docker image ls --format 'docker tag {{.Repository}}:{{.Tag}} {{.Repository}}:latest' --filter=reference='geonetwork/*' | bash - - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - - name: Push all docker images - # list all docker images, keep only the ones in the geonetwork org, and call docker push for each of them - run: | - docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=reference='geonetwork/*' | \ - xargs -r -L1 docker push $1 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 3c22b0b84b..0000000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,165 +0,0 @@ -name: Checks -run-name: 🩺 Quality assurance checks on ${{ github.event_name == 'pull_request' && 'PR' || '🌱' }} ${{ github.event_name == 'pull_request' && github.event.number || github.ref_name }} - -env: - NODE_VERSION: 18.16.1 - TEST_HIDE_CONSOLE: true - -# This workflow runs for Pull Requests which are not draft, -# as well as commits going to the default branch -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, ready_for_review] - -# Only allow concurrent checks on the main branch to keep history -# on QA checks -concurrency: - group: checks-${{ github.ref }} - cancel-in-progress: ${{ github.ref_name != 'main' }} - -jobs: - format-lint-test: - if: github.event.pull_request.draft == false - name: Format check, lint, unit tests - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' - - run: npm ci - - run: npx nx format:check - - run: npx nx affected -t lint --parallel=3 - - run: npx nx affected -t test --parallel=3 --configuration=ci --ci --codeCoverage --coverageReporters=lcov - - - name: Coveralls - uses: coverallsapp/github-action@v2 - with: - allow-empty: true - - # - name: Archive Code Coverage Results (on main) - # if: github.event_name != 'pull_request' - # uses: actions/upload-artifact@v2 - # with: - # name: code-coverage-report - # path: ./coverage/**/coverage-summary.json - # if-no-files-found: error - # - # - name: Create Code Coverage Badge (on PR) - # if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - # uses: dkhunt27/nx-code-coverage@v1 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # coverage-folder: ./coverage - # coverage-base-folder: ./coverage-base - # gist-token: ${{ secrets.COVERAGE_GIST_TOKEN }} - # gist-id: c759fcfd4e71c8853beedbe1785fc081 - # color: green - # named-logo: jest - # no-coverage-ran: false - - build-affected: - if: github.event.pull_request.draft == false - name: Attempt to build affected apps - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' - - run: npm ci - - run: npx nx affected -t build --parallel=3 - - affected-recap: - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' - name: Print affected libs and apps - runs-on: ubuntu-latest - - steps: - - name: Checkout branch - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v3 - - - name: Install dependencies - run: npm ci - - - name: Compute affected projects - run: | - echo "AFFECTED_LIBS=$(npx nx print-affected --type=lib --select=projects | awk 'BEGIN {RS = ", "; ORS = ", "} \ - { print "`"$1"`" }')" >> $GITHUB_ENV - - - name: Compute affected apps - run: | - echo "AFFECTED_APPS=$(npx nx print-affected --type=app --select=projects | awk 'BEGIN {RS = ", "; ORS = ", "} \ - { print "`"$1"`" }')" >> $GITHUB_ENV - - - name: add PR comment - uses: thollander/actions-comment-pull-request@v2 - with: - message: 'Affected libs: ${{ env.AFFECTED_LIBS }} - - Affected apps: ${{ env.AFFECTED_APPS }} - - - [ ] πŸš€ Build and deploy storybook and demo on GitHub Pages - - - [ ] πŸ“¦ Build and push affected docker images' - comment_tag: build-options - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cypress-run: - name: End-to-end tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Build the backend - run: sudo docker-compose -f support-services/docker-compose.yml up -d init - - - name: Install dependencies - run: | - npm ci - - - name: Run tests - run: npx nx run-many --target=e2e diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml deleted file mode 100644 index c11079c823..0000000000 --- a/.github/workflows/cleanup.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Cleanup -run-name: 🧹 Cleanup operations for 🌱 ${{github.event.ref}} - -env: - # a list of apps to build and publish on releases - APP_NAMES: datafeeder,datahub,metadata-editor - -on: - delete: - branches: - - '*' - -jobs: - docker-cleanup: - name: Delete docker images on Dockerhub - runs-on: ubuntu-latest - - steps: - - name: generate Dockerhub auth - id: docker-auth - run: | - BASE_64_TOKEN=$(echo '{"username":"${{ secrets.DOCKER_HUB_USERNAME }}","password":"${{ secrets.DOCKER_HUB_PASSWORD }}","auth":"","email":"geonetworkbot@geonetwork-opensource.org"}' | base64) - echo ::add-mask::${BASE_64_TOKEN} - echo ::set-output name=DOCKER_AUTH::${BASE_64_TOKEN} - - - name: delete docker images for the given applications and branch - # first list apps separated by line breaks - # then for each do a curl call on Dockerhub API to delete the image - run: | - echo "${{ env.APP_NAMES }}" | awk -vRS=',' '{print $1}' | \ - xargs -I{} curl -X DELETE "https://hub.docker.com/v2/repositories/geonetwork/geonetwork-ui-{}/${{ github.event.ref }}/" -H "X-Registry-Auth: ${{steps.docker-auth.outputs.DOCKER_AUTH}}" - - storybook-cleanup: - name: Delete storybook files on Github Pages - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Remove directory ${{github.event.ref}} - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - touch .empty - npx gh-pages --dist . --src .empty --remove "${{github.event.ref}}" --no-history --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git" diff --git a/.github/workflows/datafeeder.yaml b/.github/workflows/datafeeder.yaml new file mode 100644 index 0000000000..632b913fa7 --- /dev/null +++ b/.github/workflows/datafeeder.yaml @@ -0,0 +1,46 @@ +name: Build + +on: + push: + branches: + - georchestra-datafeeder + tags: + - '*' +jobs: + build: + if: github.repository == 'georchestra/geonetwork-ui' + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: 'Checking out' + uses: actions/checkout@v1 + + - name: Install dependencies + run: npm ci + + - name: Getting image tag + if: github.repository == 'georchestra/geonetwork-ui' + id: version + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + + - name: 'Building docker image' + if: github.repository == 'georchestra/geonetwork-ui' + run: npx nx docker-build datafeeder + + - name: 'Logging in to docker.io' + if: github.repository == 'georchestra/geonetwork-ui' + uses: azure/docker-login@v1 + with: + username: '${{ secrets.DOCKER_HUB_USERNAME }}' + password: '${{ secrets.DOCKER_HUB_PASSWORD }}' + + - name: 'Pushing latest docker image onto docker.io' + if: github.ref == 'refs/heads/georchestra-datafeeder' && github.repository == 'georchestra/geonetwork-ui' + run: | + docker push georchestra/datafeeder-frontend:latest + + - name: 'Pushing release docker image to docker.io' + if: contains(github.ref, 'refs/tags/') && github.repository == 'georchestra/geonetwork-ui' + run: | + docker tag georchestra/datafeeder-frontend:latest georchestra/datafeeder-frontend:${{ steps.version.outputs.VERSION }} + docker push georchestra/datafeeder-frontend:${{ steps.version.outputs.VERSION }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 7320553d00..0000000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Deploy -run-name: πŸš€ Deploy to GitHub Pages for ${{ github.event_name == 'issue_comment' && 'PR' || '🌱' }} ${{github.event_name == 'issue_comment' && github.event.issue.number || github.ref_name}} - -env: - NODE_VERSION: 18.16.1 - -# This workflow runs whenever the "deploy affected apps" checkbox is checked (for PR) -# or on every push to main -on: - push: - branches: - - main - issue_comment: - types: - - edited - -concurrency: - group: deploy-${{ github.ref }} - cancel-in-progress: true - -jobs: - checks: - if: github.event_name != 'issue_comment' || github.event.issue.pull_request - name: Check whether a deploy was requested on a PR - runs-on: ubuntu-latest - outputs: - shouldRun: ${{ github.event_name != 'issue_comment' || (contains(github.event.changes.body.from, '- [ ] πŸš€ Build and deploy storybook and demo on GitHub Pages') && contains(github.event.comment.body, '- [x] πŸš€ Build and deploy storybook and demo on GitHub Pages')) || '' }} - ref: ${{ github.event_name == 'issue_comment' && steps.comment-branch.outputs.head_ref || '' }} - - steps: - - uses: xt0rted/pull-request-comment-branch@v1 - if: github.event_name == 'issue_comment' - id: comment-branch - - gh-pages: - needs: checks - if: github.event_name != 'issue_comment' || needs.checks.outputs.shouldRun - name: Deploy Storybook to GitHub Pages - runs-on: ubuntu-latest - env: - BRANCH_NAME: ${{needs.checks.outputs.ref || 'main'}} - - steps: - - name: Dump GitHub event - env: - GITHUB_CONTEXT: ${{ toJson(github.event) }} - run: echo "$GITHUB_CONTEXT" - - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ needs.checks.outputs.ref }} - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: add initial comment - uses: thollander/actions-comment-pull-request@v2 - if: github.event_name == 'issue_comment' - with: - message: 'GitHub Pages links: - - - 🚧 building in progress... 🚧' - comment_tag: github-links - pr_number: ${{ github.event.issue.number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install - run: npm ci - - - name: Build storybook - run: npm run build:storybook - - - name: Build demo & web components - run: npm run build:demo - - - name: Build docs - run: npm run docs:build -- --base=/geonetwork-ui/${{env.BRANCH_NAME}}/docs/ && mkdir -p dist/docs && mv docs/.vitepress/dist/* dist/docs - - # FIXME: restore a system for testing web components but faster/lighter than storybook - # - name: Build storybook for web components - # run: npm run build:storybook-wc - - - name: Deploy to directory ${{ env.BRANCH_NAME }} - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - npx gh-pages --dist dist/ --dest ${{env.BRANCH_NAME}} --remove "${{env.BRANCH_NAME}}/**" --no-history --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git" - - - name: update PR comment - uses: thollander/actions-comment-pull-request@v2 - if: github.event_name == 'issue_comment' - with: - message: 'GitHub Pages links: - - * (Documentation)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/docs/] - - * (Demo & web components)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/demo/] - - * (UI components storybook)[https://geonetwork.github.io/geonetwork-ui/${{env.BRANCH_NAME}}/storybook/demo/]' - comment_tag: github-links - pr_number: ${{ github.event.issue.number }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/snyk-security.yml b/.github/workflows/snyk-security.yml deleted file mode 100644 index e114be3fed..0000000000 --- a/.github/workflows/snyk-security.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# A sample workflow which sets up Snyk to analyze the full Snyk platform (Snyk Open Source, Snyk Code, -# Snyk Container and Snyk Infrastructure as Code) -# The setup installs the Snyk CLI - for more details on the possible commands -# check https://docs.snyk.io/snyk-cli/cli-reference -# The results of Snyk Code are then uploaded to GitHub Security Code Scanning -# -# In order to use the Snyk Action you will need to have a Snyk API token. -# More details in https://github.com/snyk/actions#getting-your-snyk-token -# or you can signup for free at https://snyk.io/login -# -# For more examples, including how to limit scans to only high-severity issues -# and fail PR checks, see https://github.com/snyk/actions/ - -name: Snyk Security -run-name: 🐺 Run Snyk on ${{ github.event_name == 'pull_request' && 'PR' || '🌱' }} ${{ github.event_name == 'pull_request' && github.event.number || github.ref_name }} - -on: - push: - branches: ['main'] - pull_request: - types: [opened, synchronize, ready_for_review] - -permissions: - contents: read - -jobs: - security: - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/node@master - continue-on-error: true # To make sure that SARIF upload gets called - env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - with: - args: --sarif-file-output=snyk.sarif - - - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: snyk.sarif diff --git a/.github/workflows/webcomponents.yml b/.github/workflows/webcomponents.yml deleted file mode 100644 index e090eb78bb..0000000000 --- a/.github/workflows/webcomponents.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Web Components -run-name: 🧩 Build Web Components for ${{ github.event_name == 'issue_comment' && 'PR' || (github.event_name == 'release' && '🏷' || '🌱') }} ${{github.event_name == 'issue_comment' && github.event.issue.number || github.ref_name}} - -# This workflow runs whenever a commit is pushed on main or a release is published -on: - push: - branches: - - main - tags: - - 'v*.*.*' - release: - types: [published] - -concurrency: - group: webcomponents-${{ github.ref }} - cancel-in-progress: true - -env: - NODE_VERSION: 18.16.1 - PUBLISH_BRANCH: wc-dist - -jobs: - build-publish-script: - name: Build and publish the Web Components - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ needs.checks.outputs.ref }} - persist-credentials: false - fetch-depth: 0 - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Build webcomponents script - run: | - mkdir wc-dist - npm run build:demo - mv dist/demo/webcomponents/gn-wc.js wc-dist - - - name: Upload archives to release - if: github.event_name == 'release' - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: wc-dist/gn-wc.js - tag: ${{ github.ref }} - overwrite: true - - - name: Publish web component to ${{ env.PUBLISH_BRANCH }}-${{ github.ref_name }} branch - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - force_orphan: true - publish_dir: ./wc-dist - publish_branch: ${{ env.PUBLISH_BRANCH }}-${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..9546e0371e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM nginx:1.21.4-alpine + +RUN rm -rf /usr/share/nginx/html/* +COPY dist/apps/datafeeder /usr/share/nginx/html +COPY nginx-default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/apps/datafeeder/project.json b/apps/datafeeder/project.json index dce6e8a190..ec92a1cfcd 100644 --- a/apps/datafeeder/project.json +++ b/apps/datafeeder/project.json @@ -105,8 +105,8 @@ "executor": "nx:run-commands", "options": { "commands": [ - "nx build datafeeder --base-href='/datafeeder/'", - "docker build --build-arg APP_NAME=datafeeder -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datafeeder)" + "nx build datafeeder --base-href='/import/'", + "docker build . -t georchestra/datafeeder-frontend:latest" ], "parallel": false } diff --git a/apps/datafeeder/src/app/app.component.html b/apps/datafeeder/src/app/app.component.html index 0680b43f9c..3f1a5e7ba7 100644 --- a/apps/datafeeder/src/app/app.component.html +++ b/apps/datafeeder/src/app/app.component.html @@ -1 +1,7 @@ + diff --git a/apps/datafeeder/src/app/app.component.spec.ts b/apps/datafeeder/src/app/app.component.spec.ts index 9cb644a6f9..9f8f6294a3 100644 --- a/apps/datafeeder/src/app/app.component.spec.ts +++ b/apps/datafeeder/src/app/app.component.spec.ts @@ -1,24 +1,35 @@ import { TestBed } from '@angular/core/testing' import { RouterTestingModule } from '@angular/router/testing' import { AppComponent } from './app.component' +import { UtilSharedModule } from '@geonetwork-ui/util/shared' +import SETTINGS from '../settings' describe('AppComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [RouterTestingModule], + imports: [RouterTestingModule, UtilSharedModule], declarations: [AppComponent], }).compileComponents() }) - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent) - const app = fixture.componentInstance - expect(app).toBeTruthy() - }) - - it(`should have as title 'datafeeder'`, () => { - const fixture = TestBed.createComponent(AppComponent) - const app = fixture.componentInstance - expect(app.title).toEqual('datafeeder') + describe('', () => { + let fixture + let app + beforeEach(async () => { + fixture = TestBed.createComponent(AppComponent) + app = fixture.componentInstance + }) + it('should create the app', () => { + expect(app).toBeTruthy() + }) + it(`should have as title 'datafeeder'`, () => { + expect(app.title).toEqual('datafeeder') + }) + it(`should have SETTINGS.headerHeight as height`, () => { + expect(app.headerHeight).toEqual(SETTINGS.headerHeight) + }) + it(`should have SETTINGS.headerSrc as src`, () => { + expect(app.headerSrc).toEqual(SETTINGS.headerSrc) + }) }) }) diff --git a/apps/datafeeder/src/app/app.component.ts b/apps/datafeeder/src/app/app.component.ts index d35c6a2668..e0dc21366e 100644 --- a/apps/datafeeder/src/app/app.component.ts +++ b/apps/datafeeder/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core' import { ThemeService } from '@geonetwork-ui/util/shared' +import SETTINGS from '../settings' @Component({ selector: 'gn-ui-root', @@ -8,6 +9,8 @@ import { ThemeService } from '@geonetwork-ui/util/shared' }) export class AppComponent implements OnInit { title = 'datafeeder' + headerSrc = SETTINGS.headerSrc + headerHeight = SETTINGS.headerHeight ngOnInit() { ThemeService.applyCssVariables('#1EA9D5', '#EF7749', '#2E353A', '#fff') diff --git a/apps/datafeeder/src/app/app.module.ts b/apps/datafeeder/src/app/app.module.ts index 21237b8d8d..fd93e37bd7 100644 --- a/apps/datafeeder/src/app/app.module.ts +++ b/apps/datafeeder/src/app/app.module.ts @@ -38,6 +38,7 @@ import { DATAFEEDER_STATE_KEY, reducer } from './store/datafeeder.reducer' import { FeatureAuthModule } from '@geonetwork-ui/feature/auth' import { MatIconModule } from '@angular/material/icon' import { BrowserAnimationsModule } from '@angular/platform-browser/animations' +import { UtilSharedModule } from '@geonetwork-ui/util/shared' export function apiConfigurationFactory() { return new Configuration({ @@ -76,6 +77,7 @@ export function apiConfigurationFactory() { HttpClientModule, MatIconModule, UtilI18nModule, + UtilSharedModule, FeatureEditorModule, BrowserAnimationsModule, ApiModule.forRoot(apiConfigurationFactory), diff --git a/apps/datafeeder/src/index.html b/apps/datafeeder/src/index.html index 2d1b4680d1..c39b4d6cad 100644 --- a/apps/datafeeder/src/index.html +++ b/apps/datafeeder/src/index.html @@ -3,7 +3,7 @@ Datafeeder - + @@ -11,15 +11,9 @@ href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&family=Permanent+Marker&display=swap" rel="stylesheet" /> - - -
HEADER
diff --git a/apps/datafeeder/src/settings.ts b/apps/datafeeder/src/settings.ts index 339d3ff703..90168dc5f4 100644 --- a/apps/datafeeder/src/settings.ts +++ b/apps/datafeeder/src/settings.ts @@ -4,6 +4,8 @@ import { environment } from './environments/environment' const SETTING_API = `${environment.apiUrl}/config/frontend` class Settings { + headerHeight = '90px' + headerSrc = '/header/?active=import' encodings = [ { label: 'UTF-8', diff --git a/nginx-default.conf b/nginx-default.conf new file mode 100644 index 0000000000..dc4263bf6e --- /dev/null +++ b/nginx-default.conf @@ -0,0 +1,14 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html index.htm; + location ~ "^/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}.*$" { + alias /usr/share/nginx/html/index.html; + add_header "content-type" "text/html"; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/nx.json b/nx.json index 561c05319e..75a44ed38c 100644 --- a/nx.json +++ b/nx.json @@ -1,11 +1,11 @@ { "affected": { - "defaultBase": "remotes/origin/main" + "defaultBase": "remotes/origin/georchestra-datafeeder" }, "npmScope": "geonetwork-ui", "tasksRunnerOptions": { "default": { - "runner": "nx-cloud", + "runner": "nx/tasks-runners/default", "options": { "cacheableOperations": [ "build", diff --git a/proxy-config.js b/proxy-config.js index e492ffdbc8..c26fc7eb60 100644 --- a/proxy-config.js +++ b/proxy-config.js @@ -18,7 +18,10 @@ module.exports = { router: (req) => decodeURIComponent(req._parsedUrl.query), }, '/datafeeder': { - target: 'http://localhost:8181', + target: 'http://localhost:8080', + pathRewrite: { + '^/datafeeder/': '/import/', + }, secure: true, logLevel: 'debug', changeOrigin: true,