Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/memory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: memory-2026
on:
push:
branches: [develop]
jobs:
# 4.1 — TEST : exécuter "file" sur tous les JPG/JPEG
test-memory-2026:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Create test script (LF only)
shell: powershell
run: |
$lines = @(
'#!/usr/bin/env bash',
'set -euo pipefail',
'export DEBIAN_FRONTEND=noninteractive',
'apt-get update >/dev/null',
'apt-get install -y file >/dev/null',
'shopt -s globstar nullglob',
'files=(**/*.jpg **/*.jpeg)',
'if [ ${#files[@]} -eq 0 ]; then',
' echo "Aucun .jpg/.jpeg"',
' exit 0',
'fi',
'for f in "${files[@]}"; do',
' file "$f"',
'done'
)
$path = Join-Path $env:GITHUB_WORKSPACE 'test_jpgs.sh'
$content = ($lines -join "`n") # LF uniquement
[System.IO.File]::WriteAllText($path, $content, (New-Object System.Text.UTF8Encoding($false)))
- name: Run test script inside Debian (with "file")
shell: powershell
run: |
$work = $env:GITHUB_WORKSPACE -replace '\\','/'
docker run --rm --mount "type=bind,src=$work,dst=/work" -w /work debian:stable-slim bash /work/test_jpgs.sh

# 4.2 — BUILD : construire l'image <username>/memory-2026:latest
build-memory-2026:
runs-on: self-hosted
needs: test-memory-2026
steps:
- uses: actions/checkout@v4
- name: Docker build
shell: powershell
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/memory-2026:latest .

# 4.3 — PUSH : pousser sur Docker Hub
push-memory-2026:
runs-on: self-hosted
needs: build-memory-2026
steps:
- name: Sanity check secrets
shell: powershell
run: |
if (-not "${{ secrets.DOCKERHUB_USERNAME }}") { throw "Secret DOCKERHUB_USERNAME vide ou manquant" }
if (-not "${{ secrets.DOCKERHUB_TOKEN }}") { throw "Secret DOCKERHUB_TOKEN vide ou manquant" }
Write-Host "Secrets présents"
- name: Docker login (via cmd + fichier ASCII)
shell: powershell
run: |
$u = "${{ secrets.DOCKERHUB_USERNAME }}".Trim().ToLower()
$t = "${{ secrets.DOCKERHUB_TOKEN }}".Trim()
$tf = Join-Path $env:RUNNER_TEMP "dh_token.txt"
[System.IO.File]::WriteAllText($tf, $t, [System.Text.Encoding]::ASCII)
# on utilise cmd.exe pour interpréter la redirection "<"
cmd /c "docker logout 1>nul 2>nul & docker login -u $u --password-stdin < ""$tf"""
Remove-Item $tf -Force
docker info | Select-String -SimpleMatch "Username: $u" | Out-Host
- name: Docker push
shell: powershell
run: |
$u = "${{ secrets.DOCKERHUB_USERNAME }}".Trim().ToLower()
docker push "$u/memory-2026:latest"

# 4.4 — DEPLOY : SSH vers ta machine, pull & run en 80:80
deploy-memory-2026:
runs-on: self-hosted
needs: push-memory-2026
steps:
- name: Setup SSH key (Windows)
shell: powershell
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
New-Item -ItemType Directory -Force "$HOME\.ssh" | Out-Null
Set-Content -Path "$HOME\.ssh\id_rsa" -Value $env:SSH_PRIVATE_KEY -NoNewline
icacls "$HOME\.ssh\id_rsa" /inheritance:r /grant:r "$env:USERNAME:(R)" | Out-Null
- name: Deploy to target via SSH
shell: powershell
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: |
$image = "$env:DOCKERHUB_USERNAME/memory-2026:latest"
$remote = "docker pull $image; docker ps -aq -f name=^memory-2026$ | xargs -r docker rm -f; docker run -d --name memory-2026 -p 80:80 $image"
ssh -o StrictHostKeyChecking=no "$env:SSH_USER@$env:SSH_HOST" "$remote"
16 changes: 16 additions & 0 deletions .github/workflows/verify-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: verify-runner

on:
workflow_dispatch:
push:
branches: [develop]

jobs:
ping:
runs-on: self-hosted
steps:
- name: Print env
shell: powershell
run: |
Write-Host "Runner OK"
Write-Host "User: $env:USERNAME"
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM nginx:stable

RUN apt-get update && apt-get install -y --no-install-recommends file \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /var/concentration/html

COPY conf/nginx.conf /etc/nginx/nginx.conf

COPY html/ /var/concentration/html/

EXPOSE 80


CMD ["nginx", "-g", "daemon off;"]