variables:
  GIT_STRATEGY: clone

stages:
  - generate-supporting

generate_supporting_files:
  stage: generate-supporting
  image: python:3.10
  before_script:
    - apt-get update && apt-get install -y imagemagick
  script:
    - pip install --upgrade pip
    - git checkout main
    - git status
    - |
      rm -rf icons-small
      rm -rf icons-medium
      mkdir -p icons-small
      mkdir -p icons-medium
    - |
      for icon in icons/*.png; do
        small_icon="icons-small/$(basename "$icon")"
        medium_icon="icons-medium/$(basename "$icon")"
        convert "$icon" -resize 16x16 "$small_icon"
        convert "$icon" -resize 50x50 "$medium_icon"
      done
    - python scripts/generate_readme.py
    - |
      git remote set-url origin https://$CI_USER:$CI_TOKEN@gitlab.ms-ds.org/msds/icons.git
      git add *
      git config --global user.email "ci@gitlab.ms-ds.org"
      git config --global user.name "GitLab CI"
      git commit -m "Auto-updated small icons + README"
      git push -o ci.skip origin HEAD:main
  only:
    - main
