Skip to content

Commit

Permalink
chore(#1575): Provide pdf api url from the env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jul 19, 2024
1 parent 55d5739 commit 1083782
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
PDF_API_URL: ${{ secrets.PDF_API_URL}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
PDF_API_URL: ${{ secrets.PDF_API_URL }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
PDF_API_URL: ${{ secrets.PDF_API_URL}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
APP_ENV: test
PDF_API_URL: ${{ secrets.PDF_API_URL}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
PDF_API_URL: ${{ secrets.PDF_API_URL}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ changes.

### Added

-
- Add PDF_API_URL to the frontend config [Issue 1575](https://github.com/IntersectMBO/govtool/issues/1575)

### Fixed

Expand Down
4 changes: 3 additions & 1 deletion govtool/frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ VITE_NETWORK_FLAG=0
VITE_SENTRY_DSN=""
VITE_GTM_ID=""
VITE_IS_DEV=true
VITE_USERSNAP_SPACE_API_KEY=""
VITE_USERSNAP_SPACE_API_KEY=""
VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED="false"
VITE_PDF_API_URL=""
1 change: 1 addition & 0 deletions govtool/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ARG VITE_SENTRY_DSN
ARG NPMRC_TOKEN
ARG VITE_USERSNAP_SPACE_API_KEY
ARG VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='false'
ARG VITE_PDF_API_URL

ENV NODE_OPTIONS=--max_old_space_size=8192
WORKDIR /src
Expand Down
4 changes: 3 additions & 1 deletion govtool/frontend/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
, VITE_IS_DEV ? "true"
, VITE_GTM_ID ? ""
, VITE_SENTRY_DSN ? ""
, VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED ? ""
, VITE_PDF_API_URL ? ""
, CARDANO_NETWORK ? "sanchonet"
}:
let
Expand All @@ -29,7 +31,7 @@ let
name = "govtool-website";
src = frontendSrc;
buildInputs = [pkgs.yarn nodeModules];
inherit VITE_BASE_URL VITE_IS_DEV VITE_GTM_ID VITE_SENTRY_DSN VITE_NETWORK_FLAG;
inherit VITE_BASE_URL VITE_IS_DEV VITE_GTM_ID VITE_SENTRY_DSN VITE_NETWORK_FLAG VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED VITE_PDF_API_URL;
buildPhase = ''
ln -s ${nodeModules}/libexec/voltaire-voting-app/node_modules node_modules
yarn build
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/pages/ProposalDiscussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const ProposalDiscussionPillar = () => {
}
>
<ProposalDiscussion
pdfApiUrl={import.meta.env.VITE_PDF_API_URL}
walletAPI={{
...context,
...walletApi,
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/types/@intersect.mbo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum MetadataValidationStatus {
}

type ProposalDiscussionProps = {
pdfApiUrl: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
walletAPI: any;
pathname: string;
Expand Down
1 change: 1 addition & 0 deletions scripts/govtool/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ $(docker_compose_file): $(template_config_dir)/docker-compose.yml.tpl $(target_c
-e "s|<DOCKER_USER>|$(docker_user)|g" \
-e "s|<REPO_URL>|$(repo_url)|g" \
-e "s|<CSP_ALLOWED_HOSTS>|$${CSP_ALLOWED_HOSTS}|g" \
-e "s|<PDF_API_URL>|$${PDF_API_URL}|g" \
$< > $@

$(cardano_config_files): $(target_config_dir)/cardano-node/
Expand Down
2 changes: 1 addition & 1 deletion scripts/govtool/config/templates/docker-compose.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ services:
logging: *logging
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com https://www.googletagmanager.com 'self' data:; script-src 'unsafe-inline' *.usersnap.com 'self' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' *.sentry.io *.google-analytics.com *.api.pdf.gov.tools; font-src *.usersnap.com *.gstatic.com 'self' https://fonts.gstatic.com data:; worker-src blob:"
- "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com https://www.googletagmanager.com 'self' data:; script-src 'unsafe-inline' *.usersnap.com 'self' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' *.sentry.io *.google-analytics.com <PDF_API_URL>; font-src *.usersnap.com *.gstatic.com 'self' https://fonts.gstatic.com data:; worker-src blob:"
- "traefik.http.routers.to-frontend.rule=Host(`<DOMAIN>`)"
- "traefik.http.routers.to-frontend.entrypoints=websecure"
- "traefik.http.routers.to-frontend.tls.certresolver=myresolver"
Expand Down
1 change: 1 addition & 0 deletions scripts/govtool/frontend.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ build-frontend: docker-login
--build-arg VITE_USERSNAP_SPACE_API_KEY="$${USERSNAP_SPACE_API_KEY}" \
--build-arg VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED="$${IS_PROPOSAL_DISCUSSION_FORUM_ENABLED}" \
--build-arg NPMRC_TOKEN="$${NPMRC_TOKEN}" \
--build-arg VITE_PDF_API_URL="$${PDF_API_URL}" \
$(root_dir)/govtool/frontend

.PHONY: push-frontend
Expand Down

0 comments on commit 1083782

Please sign in to comment.