From c79f1d7116eba2353eca2029c20a24734c1a8b5f Mon Sep 17 00:00:00 2001 From: Elie Baier <100542666+Fayorg@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:04:10 +0100 Subject: [PATCH 1/5] add: gh action publish package --- .github/workflows/docker-publish.yml | 98 ++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..69855d2 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,98 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + schedule: + - cron: '26 22 * * *' + push: + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: fayorg/calendrier-avant + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 + with: + cosign-release: 'v2.1.1' + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} From 66ff2bc4e0ed8007e938a2954d4042635fe47ad5 Mon Sep 17 00:00:00 2001 From: Elie Baier <100542666+Fayorg@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:11:41 +0100 Subject: [PATCH 2/5] fix: removed pr & cron action --- .github/workflows/docker-publish.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 69855d2..8905ead 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,14 +6,10 @@ name: Docker # documentation. on: - schedule: - - cron: '26 22 * * *' push: branches: [ "master" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master" ] env: # Use docker.io for Docker Hub if empty From f5e5e6e7a017bbe72a2b2deef71f552760f8f97d Mon Sep 17 00:00:00 2001 From: Fayorg Date: Tue, 5 Dec 2023 21:32:50 +0100 Subject: [PATCH 3/5] fix: removed dayCard component --- components/custom/dayCard.tsx | 48 ----------------------------------- 1 file changed, 48 deletions(-) diff --git a/components/custom/dayCard.tsx b/components/custom/dayCard.tsx index 47b0d92..e69de29 100644 --- a/components/custom/dayCard.tsx +++ b/components/custom/dayCard.tsx @@ -1,48 +0,0 @@ -"use client"; - -import { BellRing, Check } from "lucide-react" - -import { cn } from "@/lib/utils" -import { Button } from "@/components/ui/button" -import { - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card" - -type CardProps = React.ComponentProps - -interface DayCardProps extends CardProps { - day: number, - name: string, - enabled: boolean -} - -export function DayCard({ className, ...props }: DayCardProps) { - return ( - - - {props.enabled ? -
-

1

-
-

Michal Polka

-

Description

-
-
- : -
-

1

-
-

Michal Polka

-

Description

-
-
- } -
-
- ) -} From d4b77139c02b50afbd54ae807537faadad1abd5c Mon Sep 17 00:00:00 2001 From: Fayorg Date: Tue, 5 Dec 2023 21:36:14 +0100 Subject: [PATCH 4/5] fix: prisma import --- app/api/grade/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/grade/route.ts b/app/api/grade/route.ts index 667d120..915438e 100644 --- a/app/api/grade/route.ts +++ b/app/api/grade/route.ts @@ -1,6 +1,6 @@ import {NextResponse} from "next/server"; -import prisma from '@lib/prisma'; +import prisma from "@/lib/prisma"; interface IBody { key: string grade: number From 2e141a19ce4c83c2a4502dca8fbfec1fd622c1f3 Mon Sep 17 00:00:00 2001 From: Fayorg Date: Tue, 5 Dec 2023 21:37:47 +0100 Subject: [PATCH 5/5] fix: removed api --- app/api/grade/route.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/api/grade/route.ts b/app/api/grade/route.ts index 915438e..5a491fb 100644 --- a/app/api/grade/route.ts +++ b/app/api/grade/route.ts @@ -7,12 +7,5 @@ interface IBody { } export async function POST(req: Request){ - const body = await req.json() as IBody - const grade = await prisma.grade.findFirst({ select: { id: true}, where: { oral: 1, key: { key: body.key } } }); - if(grade) return NextResponse.json({message: 'Deja vote'}, {status: 403}); - - const gradeCreated = await prisma.grade.create({ data: { key: { connect: { key: body.key } }, grade: body.grade, oral: 1 } }); - if(gradeCreated) return NextResponse.json({message: 'Vote enregistré'}, {status: 200}); - return NextResponse.json({message: 'Server error'}, {status: 500}) }