diff --git a/.github/workflows/release-container-image.yaml b/.github/workflows/release-container-image.yaml index 28db2e22..db7c8b01 100644 --- a/.github/workflows/release-container-image.yaml +++ b/.github/workflows/release-container-image.yaml @@ -10,73 +10,6 @@ on: - 'v*.*.*' jobs: - backend: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Prepare Image Metadata - id: prep - run: | - DOCKER_IMAGE=ghcr.io/adfinis-sygroup/customer-center/backend - VERSION=noop - if [ "${{ github.event_name }}" = "schedule" ]; then - VERSION=nightly - elif [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - elif [[ $GITHUB_REF == refs/heads/* ]]; then - VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') - if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then - VERSION=edge - fi - elif [[ $GITHUB_REF == refs/pull/* ]]; then - VERSION=pr-${{ github.event.number }} - fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - MINOR=${VERSION%.*} - MAJOR=${MINOR%.*} - TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" - elif [ "${{ github.event_name }}" = "push" ]; then - TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" - fi - echo ::set-output name=version::${VERSION} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - - - name: Login to GHCR - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - if: ${{ github.event_name != 'pull_request' }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - context: ./backend - file: ./backend/Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} - labels: | - org.opencontainers.image.title=${{ github.event.repository.name }} - org.opencontainers.image.description=${{ github.event.repository.description }} - org.opencontainers.image.url=${{ github.event.repository.html_url }} - org.opencontainers.image.source=${{ github.event.repository.clone_url }} - org.opencontainers.image.version=${{ steps.prep.outputs.version }} - org.opencontainers.image.created=${{ steps.prep.outputs.created }} - org.opencontainers.image.revision=${{ github.sha }} - org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} - frontend: runs-on: ubuntu-latest steps: @@ -135,6 +68,8 @@ jobs: build-args: | AUTH_ROLE_ADMIN=${{ secrets.AUTH_ROLE_ADMIN }} AUTH_ROLE_EMPLOYEE=${{ secrets.AUTH_ROLE_EMPLOYEE }} + TIMED_STAGING_HOST=${{ secrets.TIMED_STAGING_HOST }} + TIMED_PROD_HOST=${{ secrets.TIMED_PROD_HOST }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} labels: | diff --git a/frontend/app/adapters/application.js b/frontend/app/adapters/application.js index eeb5b9a1..4791547e 100644 --- a/frontend/app/adapters/application.js +++ b/frontend/app/adapters/application.js @@ -1,8 +1,12 @@ import JSONAPIAdapter from "@ember-data/adapter/json-api"; +import ENV from "customer-center/config/environment"; import OIDCAdapterMixin from "ember-simple-auth-oidc/mixins/oidc-adapter-mixin"; const BaseAdapter = JSONAPIAdapter.extend(OIDCAdapterMixin); export default class ApplicationAdapter extends BaseAdapter { namespace = "api/v1"; + host = window.location.host.includes("test") + ? ENV.APP.hostStaging + : ENV.APP.hostProd; } diff --git a/frontend/app/services/account.js b/frontend/app/services/account.js index bba3598a..85283521 100644 --- a/frontend/app/services/account.js +++ b/frontend/app/services/account.js @@ -1,3 +1,4 @@ +import { getOwner } from "@ember/application"; import { reads } from "@ember/object/computed"; import Service, { inject as service } from "@ember/service"; import { tracked } from "@glimmer/tracking"; @@ -31,12 +32,16 @@ export default class AccountService extends Service { async fetchCurrentUser() { try { - const response = await fetch("/api/v1/users/me", { - method: "GET", - headers: { - Authorization: `Bearer ${this.accessToken}`, - }, - }); + const adapter = getOwner(this).lookup("adapter:application"); + const response = await fetch( + `${adapter.host}/${adapter.namespace}/users/me`, + { + method: "GET", + headers: { + Authorization: `Bearer ${this.accessToken}`, + }, + } + ); const json = await response.json(); const { id } = json.data; diff --git a/frontend/config/environment.js b/frontend/config/environment.js index 89deb081..e02b5b78 100644 --- a/frontend/config/environment.js +++ b/frontend/config/environment.js @@ -38,8 +38,8 @@ module.exports = function (environment) { }, APP: { - loginRoute: "account.login", - + hostStaging: env("TIMED_STAGING_HOST", "http://localhost:8000"), + hostProd: env("TIMED_PROD_HOST", "http://localhost:8000"), // Define alertTime in hours. // When total time comes close to alertTime, text color changes. alertTime: 5,