stages:
  - build

variables:
  OPENWRT_VERSION: 23.05.3
  FILES: ${CI_PROJECT_PATH}/files
  PACKAGES: openwisp-config openwisp-monitoring netjson-monitoring

cudy_wr3000-v1:
  stage: build
  image: openwrt/imagebuilder:${TARGET}-${SUBTARGET}-${OPENWRT_VERSION}
  variables:
    TARGET: mediatek
    SUBTARGET: filogic
    PROFILE: cudy_wr3000-v1
  before_script:
    - if [[ -d ./packages ]]; then mv ./packages /builder/; fi
    - if [[ -d ./dl ]]; then mv ./dl /builder/; fi
    - for url in $(cat packages.txt); do curl --create-dirs -s -O --output-dir /builder/packages $url; done && ls -1 /builder/packages
    - cd /builder
  script:
    - make image PROFILE=${PROFILE} FILES=${FILES} PACKAGES="${PACKAGES}"
  after_script:
    - if [[ -d /builder/bin ]]; then mv /builder/bin .; fi
    - if [[ -d /builder/dl ]]; then mv /builder/dl .; fi
  cache:
    key: ${OPENWRT_VERSION}-${TARGET}
    paths:
      - dl/
  artifacts:
    paths:
      - bin/
    expire_in: 1 hour
