Commit 80576121 authored by Serafino Pirronitto's avatar Serafino Pirronitto
Browse files

Update .gitlab-ci.yml file

parent c0619534
Loading
Loading
Loading
Loading
Loading
+23 −24
Original line number Diff line number Diff line
@@ -15,10 +15,8 @@ variables:

generate_temp_docx:
  stage: preprocessing
  before_script:
    - pip3 install python-docx #install dependances
  script:
    - python3 preprocessing.py "./API.docx"
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data && python3 preprocessing.py './API.docx'"
  artifacts:
    paths:
      - temp.docx
@@ -28,55 +26,56 @@ generate_temp_docx:
images_extraction:
  stage: preprocessing
  script:
    - pandoc --extract-media ./ -f docx -t html -s API.docx -o API.html
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data && pandoc --extract-media ./ -f docx -t html -s API.docx -o API.html"
  after_script:
    - cd media
    - libreoffice --headless --convert-to png *.emf
    - mogrify -trim *.png
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data/media && libreoffice --headless --convert-to png *.emf && mogrify -trim *.png"
  artifacts:
    paths:
      - media

chunk_html:
  stage: chunk
  before_script:
    - docker pull pandoc/latex:3.1.13-alpine
  needs:
    - "generate_temp_docx"
  script:
    - docker run --entrypoint "/bin/sh" -v ./:/data pandoc/latex:3.1.13-alpine -c "pandoc --extract-media ./ -f docx -t chunkedhtml -L filter_1.lua -L filter_2.lua  --css=styling.css --css=API.css -s temp.docx -o ./API.zip --toc --toc-depth 4 --template=template.html --split-level=1"
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data && pandoc --extract-media ./ -f docx -t chunkedhtml -L filter_1.lua -L filter_2.lua  --css=styling.css --css=API.css -s temp.docx -o ./API.zip --toc --toc-depth 4 --template=template.html --split-level=1"
  artifacts:
    paths:
      - ./API.zip


saving_script:
  stage: build
  stage: chunk
  needs:
    - "chunk_html"
    - "images_extraction"
  before_script:
    - mkdir API
    - unzip ./API.zip /API
    - cd docx_to_html
    - unzip ./API.zip -d ./API
    - cp -r ./dist ./API
    - cd ./API
    - npm install --save puppeteer fs
    - cp pre-save_script.js ./API
  script:
    - node pre-save_script.js
    - cd saved_files
    - for file in *_updated*; do mv "$file" "$(echo "../$file" | sed 's/_updated//g')"; done
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./API:/data" node:20-alpine3.20 -c "cd data && npm init -y && npm install --save puppeteer fs &&\
      apk --update --upgrade add chromium && export ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium-browser &&\
      node pre-save_script.js && rm ./*.html && cd saved_files && for file in *_updated*; do mv "$file" "$(echo "../$file" | sed 's/_updated//g')"; done"
  artifacts:
    paths:
      - "./API/saved_files/"

      - docx_to_html/API/

docx:
  stage: build
  before_script:
    - pip3 install python-docx && pip3 install cssutils && pip3 install beautifulsoup4 #install dependances
    - docker pull serafinopirronitto/test-image:v3
  needs:
    - "saving_script"
  script:
    - docker run --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data && python3 html_to_docx.py ./API && python3 postprocessing.py html_to_docx_output.docx ./media"
    - docker run -u $(id -u):$(id -g) --entrypoint "/bin/sh" -v "./:/data" serafinopirronitto/test-image:v3 -c "cd data && python3 html_to_docx.py ./API && python3 postprocessing.py html_to_docx_output.docx ./media"
  artifacts:
    paths:
      - html_to_docx_output_fixed.docx

pages:
  stage: deploy
  needs:
    - "docx"
  script: #copy into public everything it needs to make the page work
    - cp ./API/saved_files/* public/ #html files
    - cp API.css background_highlight.css public/ #css files