Skip to content

Commit

Permalink
Merge pull request #336 from OpenCatalogi/feature/OP-56/deployment-wo…
Browse files Browse the repository at this point in the history
…rkflow

Feature/op 56/deployment workflow
  • Loading branch information
lencodes authored Sep 27, 2023
2 parents 76fb4e9 + 09fa80a commit ff98d6a
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 36 deletions.
47 changes: 27 additions & 20 deletions .github/workflows/opencatalogi-page-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ env: # Change these to your preferences any image url can also be a base encoded
USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: "true"

GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
API_BASE_URL: "https://api.gateway.commonground.nu/api"
NL_DESIGN_THEME_CLASSNAME: "conduction-theme"
FAVICON_URL: "https://conduction.nl/wp-content/uploads/2021/07/cropped-favicon-32x32.png"
HEADER_LOGO_URL: "https://conduction.nl/wp-content/uploads/2021/07/cropped-conductionlogo-1.png"
ORGANISATION_NAME: "Conduction"
JUMBOTRON_IMAGE_URL: "https://www.conduction.nl/wp-content/uploads/2021/07/cropped-Conduction_HOME_0000_afb1-1.png"
FOOTER_LOGO_URL: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICAgICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4wIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICAgd2lkdGg9IjcxLjAwMDAwMHB0IiBoZWlnaHQ9IjcwLjAwMDAwMHB0IiB2aWV3Qm94PSIwIDAgNzEuMDAwMDAwIDcwLjAwMDAwMCIKICAgICBwcmVzZXJ2ZUFzcGVj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N_NUMBER: " "

ME_URL: "https://api.opencatalogi.nl/api/users/me"
API_URL: "https://api.opencatalogi.nl/api"
ADMIN_URL: "https://api.opencatalogi.nl/admin"
BASE_URL: "https://api.opencatalogi.nl"
FRONTEND_URL: "https://api.opencatalogi.nl"
LOGIN_REDIRECT: "vault"
ADMIN_DASHBOARD_URL: "https://admin.opencatalogi.nl"

NL_DESIGN_THEME_CLASSNAME: rotterdam-theme
ARROW_BREADCRUMBS: "false"

# GITHUB_ORGANIZATION_URL: ""

on:
push:
branches:
- never
- main
- development

jobs:
build:
Expand All @@ -37,17 +42,19 @@ jobs:
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_GITHUB_REPOSITORY_NAME: ${{ env.GITHUB_REPOSITORY_NAME }}
envkey_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: ${{ env.USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX }}
envkey_GATSBY_API_BASE_URL: ${{ env.API_BASE_URL }}
envkey_GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: ${{ env.USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX }}
envkey_GATSBY_GITHUB_REPOSITORY_NAME: ${{ env.GITHUB_REPOSITORY_NAME }}
envkey_GATSBY_ME_URL: ${{ env.ME_URL }}
envkey_GATSBY_API_URL: ${{ env.API_URL }}
envkey_GATSBY_ADMIN_URL: ${{ env.ADMIN_URL }}
envkey_GATSBY_BASE_URL: ${{ env.BASE_URL }}
envkey_GATSBY_FRONTEND_URL: ${{ env.FRONTEND_URL }}
envkey_GATSBY_LOGIN_REDIRECT: ${{ env.LOGIN_REDIRECT }}
envkey_GATSBY_ADMIN_DASHBOARD_URL: ${{ env.ADMIN_DASHBOARD_URL }}
envkey_GATSBY_NL_DESIGN_THEME_CLASSNAME: ${{ env.NL_DESIGN_THEME_CLASSNAME }}
envkey_GATSBY_FAVICON_URL: ${{ env.FAVICON_URL }}
envkey_GATSBY_HEADER_LOGO_URL: ${{ env.HEADER_LOGO_URL }}
envkey_GATSBY_ORGANISATION_NAME: ${{ env.ORGANISATION_NAME }}
envkey_GATSBY_JUMBOTRON_IMAGE_URL: ${{ env.JUMBOTRON_IMAGE_URL }}
envkey_GATSBY_FOOTER_LOGO_URL: ${{ env.FOOTER_LOGO_URL }}
envkey_GATSBY_FOOTER_LOGO_HREF: ${{ env.FOOTER_LOGO_HREF }}
# envkey_GATSBY_OIDN_NUMBER: ${{ env.OIDN_NUMBER }}
envkey_GATSBY_ARROW_BREADCRUMBS: ${{ env.ARROW_BREADCRUMBS }}

# envkey_GATSBY_GITHUB_ORGANIZATION_URL: ${{ env.GITHUB_ORGANIZATION_URL }}
directory: pwa/static
file_name: .env.production
fail_on_empty: true
Expand Down
4 changes: 4 additions & 0 deletions pwa/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ require("dotenv").config({
});

module.exports = {
pathPrefix:
process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true"
? `/${process.env.GATSBY_GITHUB_REPOSITORY_NAME}`
: "", // we do NOT want to set the prefix if we're using an DNS
plugins: [
{
resolve: `gatsby-plugin-layout`,
Expand Down
7 changes: 3 additions & 4 deletions pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"private": true,
"description": "skeleton-pip",
"author": "Conduction",
"keywords": [
"gatsby"
],
"keywords": ["gatsby"],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"build": "gatsby build --prefix-paths",
"deploy": "gatsby build --prefix-paths && gh-pages -d public",
"serve": "gatsby serve",
"clean": "gatsby clean",
"lint": "npm-run-all lint:** ",
Expand Down
16 changes: 9 additions & 7 deletions pwa/src/apiService/resources/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export default class Search {
}

public getSearch = async (filters: IFilters): Promise<any> => {
const { data } = await Send(
this._instance,
"GET",
`/search?page=${
filters.currentPage
}&order[embedded.rating.rating]=desc&limit=10&extend[]=all${filtersToQueryParams(filters)}`,
);
let endpoint = `/search?page=${
filters.currentPage
}&order[embedded.rating.rating]=desc&limit=10&extend[]=all${filtersToQueryParams(filters)}`;

if (process.env.GATSBY_GITHUB_ORGANIZATION_URL) {
endpoint += `&legal.repoOwner.github=${process.env.GATSBY_GITHUB_ORGANIZATION_URL}`;
}

const { data } = await Send(this._instance, "GET", endpoint);

return data;
};
Expand Down
11 changes: 10 additions & 1 deletion pwa/src/templates/templateParts/header/HeaderTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface HeaderTemplateProps {

export const HeaderTemplate: React.FC<HeaderTemplateProps> = ({ layoutClassName }) => {
const { t } = useTranslation();
const [isHomePage, setIsHomePage] = React.useState<boolean>(false);
const [filters, setFilters] = React.useContext(FiltersContext);
const [topNavItems, setTopNavItems] = React.useState<any[]>([]);

Expand All @@ -44,6 +45,14 @@ export const HeaderTemplate: React.FC<HeaderTemplateProps> = ({ layoutClassName
navigate(pathname);
};

React.useEffect(() => {
setIsHomePage(
pathname === "/" ||
(process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" &&
pathname === `/${process.env.GATSBY_GITHUB_REPOSITORY_NAME}/`),
);
}, [pathname]);

const primaryTopNavItems = [
{
label: "Home",
Expand Down Expand Up @@ -182,7 +191,7 @@ export const HeaderTemplate: React.FC<HeaderTemplateProps> = ({ layoutClassName
</Container>
</div>

{pathname === "/" && (
{isHomePage && (
<Container layoutClassName={styles.headerContent}>
<section className={clsx(styles.headerSearchForm, styles.section)}>
<div>
Expand Down
8 changes: 6 additions & 2 deletions pwa/static/.env.development
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
GATSBY_GITHUB_REPOSITORY_NAME=web-app
# options: "true" | "false"
GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX=true

# Backend-config
GATSBY_ME_URL=https://api.opencatalogi.nl/api/users/me
GATSBY_API_URL=https://api.opencatalogi.nl/api
GATSBY_ADMIN_URL=https://api.opencatalogi.nl/admin
GATSBY_BASE_URL=https://api.opencatalogi.nl
GATSBY_FRONTEND_URL=https://api.opencatalogi.nl
GATSBY_ORGANIZATION=""
GATSBY_LOGIN_REDIRECT=vault
GATSBY_ADMIN_DASHBOARD_URL=https://admin.opencatalogi.nl

# Config
GATSBY_NL_DESIGN_THEME_CLASSNAME=rotterdam-theme
GATSBY_ARROW_BREADCRUMBS="false"
GATSBY_ARROW_BREADCRUMBS=false
# GATSBY_GITHUB_ORGANIZATION_URL=""
9 changes: 7 additions & 2 deletions pwa/static/.env.production
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
GATSBY_GITHUB_REPOSITORY_NAME=
# options: "true" | "false"
GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX=


# Backend-config
GATSBY_ME_URL=
GATSBY_API_URL=
GATSBY_ADMIN_URL=
GATSBY_BASE_URL=
GATSBY_FRONTEND_URL=
GATSBY_ORGANIZATION=
GATSBY_LOGIN_REDIRECT=
GATSBY_ADMIN_DASHBOARD_URL=

# Config
GATSBY_NL_DESIGN_THEME_CLASSNAME=
GATSBY_ARROW_BREADCRUMBS=
GATSBY_ARROW_BREADCRUMBS=
# GATSBY_GITHUB_ORGANIZATION_URL=

0 comments on commit ff98d6a

Please sign in to comment.