Skip to content

Commit

Permalink
Merge pull request #1388 from swisstopo/feature/viewer-1351-config-au…
Browse files Browse the repository at this point in the history
…slagern

Feature 1351 Config auslagern
  • Loading branch information
vej-ananas authored Nov 20, 2024
2 parents 0498c0d + ac29e10 commit 6fef90b
Show file tree
Hide file tree
Showing 43 changed files with 3,155 additions and 2,909 deletions.
22 changes: 11 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
root = true

[*.js]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
root = true

[{*.js,*.ts}]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock.json -diff
* -text
264 changes: 132 additions & 132 deletions .github/workflows/publish-edge.yml
Original file line number Diff line number Diff line change
@@ -1,132 +1,132 @@
name: Publish Edge

on:
push:
branches:
- "develop"

workflow_dispatch:
inputs:
version:
type: string
description: |
Version number (e.g. 1.2.3-dev1).
Leave empty to determine the next version automatically.
required: false
default: ""
is-edge:
type: boolean
description: "Tag the commit and published image with `edge`."
default: true

permissions: write-all

env:
IS_EDGE: ${{ github.event_name == 'push' || github.event.inputs.is-edge == 'true' }}

jobs:
determine_version:
name: "determine version"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.find_version.outputs.result || github.event.inputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
if: ${{ github.event.inputs.version == '' }}
- name: Get tags of edge commit
id: get_edge_tags
if: ${{ github.event.inputs.version == '' }}
run: |
git fetch --tags
EDGE_COMMIT=$(git rev-list -n 1 edge)
EDGE_TAGS=$(printf "%s," $(git tag --contains $EDGE_COMMIT))
EDGE_TAGS=${EDGE_TAGS%,}
echo "edge_tags=$EDGE_TAGS" >> "$GITHUB_OUTPUT"
- name: Find next version
id: find_version
if: ${{ github.event.inputs.version == '' }}
uses: actions/github-script@v7
env:
EDGE_TAGS: ${{ steps.get_edge_tags.outputs.edge_tags }}
with:
result-encoding: string
script: |
const { findNextVersion } = require('./.github/scripts/find-version.js');
const tags = process.env.EDGE_TAGS.split(',');
const targetBranch = context.payload.ref.replace('refs/heads/', '');
const pullRequests = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
base: targetBranch,
sort: 'updated',
direction: 'desc'
});
const mergedPullRequest = pullRequests.data.find(pr => pr.merge_commit_sha === context.payload.after);
const sourceBranch = mergedPullRequest == null
? targetBranch
: mergedPullRequest.head.ref.replace('refs/heads/', '')
const version = findNextVersion(tags, sourceBranch);
return `${version.major}.${version.minor}.${version.patch}-dev${version.preRelease}`;
build_and_push_api:
name: "build and push api"
needs:
- determine_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create image
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ vars.BASE_IMAGE_NAME }}-api
TAG: ${{ env.IS_EDGE == 'true' && 'edge' || '' }}
VERSION: ${{ needs.determine_version.outputs.version }}
DOCKERFILE: ./api/Dockerfile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTEXT: ./api

build_and_push_ui:
name: "build and push ui"
needs:
- determine_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create image
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ vars.BASE_IMAGE_NAME }}-ui
TAG: ${{ env.IS_EDGE == 'true' && 'edge' || '' }}
VERSION: ${{ needs.determine_version.outputs.version }}
DOCKERFILE: ./ui/Dockerfile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTEXT: ./ui

tag_commit:
name: "tag commit"
needs:
- determine_version
- build_and_push_api
- build_and_push_ui
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: tag edge
if: ${{ env.IS_EDGE == 'true' }}
uses: ./.github/actions/tag-commit
with:
TAG_NAME: edge
SHA: ${{ github.sha }}
- name: tag version
uses: ./.github/actions/tag-commit
with:
TAG_NAME: ${{ needs.determine_version.outputs.version }}
SHA: ${{ github.sha }}
name: Publish Edge

on:
push:
branches:
- "develop"

workflow_dispatch:
inputs:
version:
type: string
description: |
Version number (e.g. 1.2.3-dev1).
Leave empty to determine the next version automatically.
required: false
default: ""
is-edge:
type: boolean
description: "Tag the commit and published image with `edge`."
default: true

permissions: write-all

env:
IS_EDGE: ${{ github.event_name == 'push' || github.event.inputs.is-edge == 'true' }}

jobs:
determine_version:
name: "determine version"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.find_version.outputs.result || github.event.inputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
if: ${{ github.event.inputs.version == '' }}
- name: Get tags of edge commit
id: get_edge_tags
if: ${{ github.event.inputs.version == '' }}
run: |
git fetch --tags
EDGE_COMMIT=$(git rev-list -n 1 edge)
EDGE_TAGS=$(printf "%s," $(git tag --contains $EDGE_COMMIT))
EDGE_TAGS=${EDGE_TAGS%,}
echo "edge_tags=$EDGE_TAGS" >> "$GITHUB_OUTPUT"
- name: Find next version
id: find_version
if: ${{ github.event.inputs.version == '' }}
uses: actions/github-script@v7
env:
EDGE_TAGS: ${{ steps.get_edge_tags.outputs.edge_tags }}
with:
result-encoding: string
script: |
const { findNextVersion } = require('./.github/scripts/find-version.js');
const tags = process.env.EDGE_TAGS.split(',');
const targetBranch = context.payload.ref.replace('refs/heads/', '');
const pullRequests = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
base: targetBranch,
sort: 'updated',
direction: 'desc'
});
const mergedPullRequest = pullRequests.data.find(pr => pr.merge_commit_sha === context.payload.after);
const sourceBranch = mergedPullRequest == null
? targetBranch
: mergedPullRequest.head.ref.replace('refs/heads/', '')
const version = findNextVersion(tags, sourceBranch);
return `${version.major}.${version.minor}.${version.patch}-dev${version.preRelease}`;
build_and_push_api:
name: "build and push api"
needs:
- determine_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create image
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ vars.BASE_IMAGE_NAME }}-api
TAG: ${{ env.IS_EDGE == 'true' && 'edge' || '' }}
VERSION: ${{ needs.determine_version.outputs.version }}
DOCKERFILE: ./api/Dockerfile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTEXT: ./api

build_and_push_ui:
name: "build and push ui"
needs:
- determine_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create image
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ vars.BASE_IMAGE_NAME }}-ui
TAG: ${{ env.IS_EDGE == 'true' && 'edge' || '' }}
VERSION: ${{ needs.determine_version.outputs.version }}
DOCKERFILE: ./ui/Dockerfile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTEXT: ./ui

tag_commit:
name: "tag commit"
needs:
- determine_version
- build_and_push_api
- build_and_push_ui
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: tag edge
if: ${{ env.IS_EDGE == 'true' }}
uses: ./.github/actions/tag-commit
with:
TAG_NAME: edge
SHA: ${{ github.sha }}
- name: tag version
uses: ./.github/actions/tag-commit
with:
TAG_NAME: ${{ needs.determine_version.outputs.version }}
SHA: ${{ github.sha }}
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/swissgeol-viewer-app.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/webResources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

### Changed

- Config is loaded from the frontend at runtime now.

### Fixed
5 changes: 5 additions & 0 deletions api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Application
APP_PORT=3000
ENV=dev

# Database
PGUSER=www-data
Expand All @@ -29,4 +30,8 @@ S3_ENDPOINT=http://minio:9000
# Cognito
COGNITO_AWS_REGION=eu-west-1
COGNITO_CLIENT_ID=10h1tga4i933buv25lelalmtrn
COGNITO_IDENTITY_POOL_ID=eu-west-1:aa0d145d-228e-40be-bb73-a9a2c83879df
COGNITO_POOL_ID=eu-west-1_dbfEb2FuH

# ION
ION_DEFAULT_ACCESS_TOKEN='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0YjNhNmQ4My01OTdlLTRjNmQtYTllYS1lMjM0NmYxZTU5ZmUiLCJpZCI6MTg3NTIsInNjb3BlcyI6WyJhc2wiLCJhc3IiLCJhc3ciLCJnYyJdLCJpYXQiOjE1NzQ0MTAwNzV9.Cj3sxjA_x--bN6VATcN4KE9jBJNMftlzPuA8hawuZkY'
Loading

0 comments on commit 6fef90b

Please sign in to comment.