Skip to content

Conversation

@Baptiiiiste
Copy link
Owner

No description provided.

* ADD - Implement CI workflow

* UPD - Refactor CI workflow to remove duplicate pnpm setup step

* UPD - Refactor CI workflow to remove duplicate pnpm setup step

* UPD - Simplify request handling by directly using params.uuid

* UPD - Simplify request handling by directly using params.uuid

* UPD - Simplify request handling by directly using params.uuid

* UPD - Simplify request handling by directly using params.uuid

* UPD - Update route parameter handling to use Promise for uuid extraction

* UPD - Update route parameter handling to use Promise for uuid extraction

* UPD - Enhance CI configuration by adding Docker metadata extraction and updating image tags

* UPD - Enhance CI configuration by adding Docker metadata extraction and updating image tags

* UPD - Add step to generate Prisma Client in CI configuration

* UPD - Add step to generate Prisma Client in CI configuration

* UPD - Update Dockerfile to generate Prisma Client and optimize production dependencies

* UPD - Update Dockerfile to generate Prisma Client and optimize production dependencies

* UPD - Refactor CI configuration to improve environment variable handling and streamline deployment conditions

* UPD - Simplify CI configuration by removing environment input and directly setting deployment environments

* UPD - Update CI configuration to enforce manual deployment conditions for dev and prod environments

* UPD - Add CI workflows for manual deployment to DEV and PROD environments

* UPD - Enhance CI configuration to support manual deployment to DEV and PROD environments

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI

* UPD - CI
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Comment on lines 19 to 50
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Generate Prisma Client
run: pnpm prisma generate

- name: Skip tests (no test script defined)
run: echo "⚠️ Aucun test défini, étape ignorée."

- name: Build app
run: pnpm build


# 2️⃣ Build & push Docker image
docker-build-push:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To fix the problem, explicitly set the minimal required permissions: for the build-and-test job. Since the steps in build-and-test only check out code, install dependencies, generate code, and build the app—and do not need to write to the repository—the minimal permission block should be contents: read. This prevents the job from inheriting potentially broad permissions from the repository's defaults. Add the block directly under the job definition (line 15, after runs-on) for clarity and granularity.


Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,6 +14,8 @@
   # 1️⃣ Build & tests
   build-and-test:
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
 
     steps:
       - name: Checkout code
EOF
@@ -14,6 +14,8 @@
# 1️⃣ Build & tests
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Comment on lines 94 to 120
runs-on: self-hosted
needs: docker-build-push

steps:
- name: Clean workspace
run: rm -rf *

- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull new image + restart stack
run: |
echo "🔧 Deploying on the server..."
cd /home/baptiste/Dev/WPT/dev
docker-compose pull
docker rm -f wpt-dev_website || true
docker-compose up -d --remove-orphans
echo "🚀 Deployed in DEV!"

deploy-prod:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To fix this problem, we should explicitly set a permissions block for the deploy-dev job in the .github/workflows/ci.yml workflow file. The minimal starting point, as recommended, is to restrict the GitHub token permissions to contents: read, unless more privileges are needed (which is not indicated by the job's steps).

Specifically, add a permissions block to the deploy-dev job:

deploy-dev:
  runs-on: self-hosted
  needs: docker-build-push
  permissions:
    contents: read
  # ...

This change should be added immediately after the existing needs: docker-build-push line (line 90), before steps:.

No new methods, imports, or other code modifications are necessary.


Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -88,6 +88,8 @@
   deploy-dev:
     runs-on: self-hosted
     needs: docker-build-push
+    permissions:
+      contents: read
 
     steps:
       - name: Clean workspace
EOF
@@ -88,6 +88,8 @@
deploy-dev:
runs-on: self-hosted
needs: docker-build-push
permissions:
contents: read

steps:
- name: Clean workspace
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
* UPD - CI

* UPD - CI
Comment on lines +117 to +141
runs-on: self-hosted
needs: docker-build-push
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
- name: Clean workspace
run: rm -rf *

- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull new image + restart PROD stack
run: |
echo "🔧 Deploying on PROD..."
cd /home/baptiste/Dev/WPT/prod
docker-compose pull
docker rm -f wpt_website || true
docker-compose up -d --remove-orphans
echo "🚀 Deployed in PROD!"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To fix the problem, add a permissions block to the deploy-prod job, restricting the GITHUB_TOKEN to the least required privileges (likely contents: read). This ensures that the deploy-prod job cannot unexpectedly write to source code or other resources via the token. Place the following block directly under the runs-on and above needs (or immediately after needs, if preferred for consistency):

permissions:
  contents: read

This matches the minimal usage for jobs that only need to fetch code or authenticate for Docker pulls. Review other self-hosted jobs (deploy-dev), and add a similar block if appropriate, but CodeQL only explicitly flagged deploy-prod, so let's just do that per instructions. No imports or other definitions are necessary—just a YAML block.


Suggested changeset 1
.github/workflows/ci.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -115,6 +115,8 @@
   # 4️⃣ Deploy PROD (skip par défaut, relançable sur main)
   deploy-prod:
     runs-on: self-hosted
+    permissions:
+      contents: read
     needs: docker-build-push
     if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
     steps:
EOF
@@ -115,6 +115,8 @@
# 4️⃣ Deploy PROD (skip par défaut, relançable sur main)
deploy-prod:
runs-on: self-hosted
permissions:
contents: read
needs: docker-build-push
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants