Skip to content

Commit

Permalink
chore: add proper redirects for non-prod docs envs (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
FRSgit authored Nov 13, 2024
1 parent d2d8eef commit 6d69b69
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs-vue-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
ARTIFACT_TYPE: 'sfui2-docs'
DOCKERFILE_PATH: './.vuestorefrontcloud/docs/Dockerfile'
ENVIRONMENT: ${{ needs.configure-enviroment.outputs.environment }}
TARGET_DOMAIN: ${{ needs.configure-enviroment.outputs.target-domain }}

sync-assets:
needs: [build, configure-enviroment]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-router-vue-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
ARTIFACT_TYPE: "vue-storefront"
DOCKERFILE_PATH: ".vuestorefrontcloud/router/docker/Dockerfile"
ENVIRONMENT: ${{ needs.configure-enviroment.outputs.environment }}
TARGET_DOMAIN: ${{ needs.configure-enviroment.outputs.target-domain }}

deploy:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-test-next-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
ARTIFACT_TYPE: "sfui2-docs-react"
DOCKERFILE_PATH: ".vuestorefrontcloud/test-next/docker/Dockerfile"
ENVIRONMENT: ${{ needs.configure-enviroment.outputs.environment }}
TARGET_DOMAIN: ${{ needs.configure-enviroment.outputs.target-domain }}

deploy:
needs: [ build, configure-enviroment ]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-test-nuxt-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
ARTIFACT_TYPE: "sfui2-docs-vue"
DOCKERFILE_PATH: ".vuestorefrontcloud/test-nuxt/docker/Dockerfile"
ENVIRONMENT: ${{ needs.configure-enviroment.outputs.environment }}
TARGET_DOMAIN: ${{ needs.configure-enviroment.outputs.target-domain }}

deploy:
needs: [ build, configure-enviroment ]
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/image-build-vue-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
ENVIRONMENT:
required: true
type: string
TARGET_DOMAIN:
required: true
type: string

jobs:
build:
Expand All @@ -29,11 +32,12 @@ jobs:
uses: elgohr/Publish-Docker-Github-Action@v5
env:
ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
TARGET_DOMAIN: ${{ inputs.TARGET_DOMAIN }}
with:
name: ${{ inputs.DOCKER_NAMESPACE }}/${{ inputs.ARTIFACT_TYPE }}:${{ github.sha }}
registry: registry.storefrontcloud.io
username: ${{ secrets.CLOUD_USERNAME }}
password: ${{ secrets.CLOUD_PASSWORD }}
dockerfile: ${{ inputs.DOCKERFILE_PATH }}
buildoptions: '--compress'
buildargs: VITE_DOCS_BASEPATH,VITE_DOCS_EXAMPLES_REACT_PATH,VITE_DOCS_EXAMPLES_VUE_PATH,ENVIRONMENT
buildargs: VITE_DOCS_BASEPATH,VITE_DOCS_EXAMPLES_REACT_PATH,VITE_DOCS_EXAMPLES_VUE_PATH,ENVIRONMENT,TARGET_DOMAIN
9 changes: 8 additions & 1 deletion .vuestorefrontcloud/router/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
FROM nginx
COPY .vuestorefrontcloud/router/docker/default.conf /etc/nginx/conf.d/default.conf

ARG TARGET_DOMAIN

ENV TARGET_DOMAIN=$TARGET_DOMAIN

COPY .vuestorefrontcloud/router/docker/default.conf.template /etc/nginx/conf.d/default.conf.template

RUN envsubst < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ server {

# https://www.oliverdavies.uk/blog/nginx-redirects-query-string-arguments
location / {
return 301 https://docs.storefrontui.io/v2$uri$is_args$args;
return 301 ${TARGET_DOMAIN}/v2$uri$is_args$args;
}
}

0 comments on commit 6d69b69

Please sign in to comment.