Skip to content

Commit

Permalink
Merge branch 'staging' into implement-gql
Browse files Browse the repository at this point in the history
  • Loading branch information
dupreesi committed Jul 30, 2024
2 parents d947cd4 + a591c35 commit 8cc3b8a
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 133 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Create and publish a Docker image
on:
workflow_call:
inputs:
jelastic_env:
description: 'Jelastic environment name'
required: true
type: string
image_name:
description: 'Name for image'
required: false
default: ${{ github.repository }}
type: string
secrets:
jelastic_access_token:
required: true
shopify_api_key:
required: true

jobs:
build-and-push-image:
runs-on: ubuntu-latest
env:
SHOPIFY_API_KEY: ${{ secrets.shopify_api_key }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=sha,prefix={{branch}}-
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
build-args: |
SHOPIFY_API_KEY=${{ secrets.shopify_api_key }}
tags: ghcr.io/${{ inputs.image_name }}:${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true
- name: Redeploy containers
run: |
sudo apt-get install curl -y
curl https://app.jpc.infomaniak.com/1.0/environment/control/rest/redeploycontainersbygroup?envName=${{inputs.jelastic_env}}\&session=${{secrets.jelastic_access_token}}\&tag=${{steps.meta.outputs.tags}}\&nodeGroup=cp
18 changes: 18 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Create and publish a Docker image

on:
push:
branches: ['staging']

jobs:
build-and-push-image:
permissions:
contents: read
packages: write
attestations: write
id-token: write
uses: ./.github/workflows/build-and-deploy.yml
with:
jelastic_env: env-9448736
secrets: inherit

1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:18-alpine

ARG SHOPIFY_API_KEY
ENV SHOPIFY_API_KEY=$SHOPIFY_API_KEY

EXPOSE 8081
WORKDIR /app
COPY web .
Expand Down
50 changes: 0 additions & 50 deletions web/frontend/pages/SalesSession.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,6 @@ export default function SalesSession() {
},
});

const {
mutateAsync: editCurrentSalesSession,
isLoading: editCurrentSalesSessionIsLoading,
error: editCurrentSalesSessionError,
} = useAppMutation({
reactQueryOptions: {
onSuccess: async () => {
await queryClient.invalidateQueries("/api/sales-session");
setShowSuccessAlert({
show: true,
type: "updated",
});
},
},
});

const {
mutateAsync: completeCurrentSalesSession,
isLoading: completeCurrentSalesSessionIsLoading,
Expand Down Expand Up @@ -134,22 +118,6 @@ export default function SalesSession() {
},
});

const handleOnEditCurrentSalesSessionClick = async () => {
await editCurrentSalesSession({
url: "/api/sales-session/current",
fetchInit: {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
startDate: startDate.toISOString(),
sessionDurationInDays: Number(sessionDurationInDays),
}),
},
});
};

const handleOnFinishCurrentSalesSessionClick = async () => {
await completeCurrentSalesSession({
url: "/api/sales-session/current/complete",
Expand Down Expand Up @@ -314,20 +282,6 @@ export default function SalesSession() {
{createSalesSessionIsLoading ? "Loading..." : "Create Sales Session"}
</Button>

<Button
variant="contained"
type="button"
onClick={handleOnEditCurrentSalesSessionClick}
disabled={
editCurrentSalesSessionIsLoading ||
!currentSalesSessionData?.currentSalesSession?.isActive
}
>
{editCurrentSalesSessionIsLoading
? "Loading..."
: "Edit Current Sales Session"}
</Button>

<Button
variant="contained"
type="button"
Expand All @@ -346,10 +300,6 @@ export default function SalesSession() {
<Alert severity="error">{createSalesSessionError.message}</Alert>
)}

{editCurrentSalesSessionError && (
<Alert severity="error">{editCurrentSalesSessionError.message}</Alert>
)}

{completeCurrentSalesSessionError && (
<Alert severity="error">
{completeCurrentSalesSessionError.message}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions web/modules/sales-session/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Router } from 'express';

import createSalesSession from './create-sales-session.js';
import getCurrentSalesSession from './get-current-sales-session.js';
import editCurrentSalesSession from './edit-current-sales-session.js';
import deleteCurrentSalesSession from './delete-current-sales-session.js';
import completeCurrentSalesSession from './complete-current-sales-session.js';

Expand All @@ -11,7 +10,6 @@ const salesSessionRouter = Router();
salesSessionRouter.post('/', createSalesSession);
salesSessionRouter.get('/', getCurrentSalesSession);
salesSessionRouter.delete('/current', deleteCurrentSalesSession);
salesSessionRouter.patch('/current', editCurrentSalesSession);
salesSessionRouter.patch('/current/complete', completeCurrentSalesSession);

export default salesSessionRouter;
30 changes: 0 additions & 30 deletions web/modules/sales-session/use-cases/edit-current-sales-session.js

This file was deleted.

2 changes: 1 addition & 1 deletion web/oidc-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ oidcRouter.get('/success', async (req, res) => {
res
.status(200)
.set('Content-Type', 'text/html')
.send(readFileSync(join(STATIC_PATH, 'success.html')))
.send(readFileSync(join(STATIC_PATH, 'success.html')));
});

oidcRouter.get(
Expand Down
6 changes: 1 addition & 5 deletions web/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ export function getShopifyIdSubstring(url) {
}

export function throwError(message, errorObj) {
if (errorObj) {
throw errorObj;
} else {
throw new Error(message);
}
throw new Error(message, errorObj ? { cause: errorObj } : null);
}

export function getTargetStringFromSemanticId(url, key) {
Expand Down

0 comments on commit 8cc3b8a

Please sign in to comment.