image: ubuntu:latest

#
#.install_firefox_geckodriver: &install_firefox_geckodriver


before_script:
  - apt-get update -y
  - apt install -y python3-pip python3.10 python-is-python3
  - apt install -y xvfb libssl-dev openssl wget
  - openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes -batch
#  -  sudo -H pip3 install bpython selenium

  - apt-get update # && apt-get upgrade --assume-yes
  - apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils --assume-yes
  - wget -nv -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"
  - tar xjf ~/FirefoxSetup.tar.bz2 -C /opt/
  - ln -s /opt/firefox/firefox /usr/lib/firefox
  - export PATH=$PATH:/opt/firefox/
  - wget -nv -O ~/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz"
  - tar -zxvf ~/geckodriver.tar.gz -C /opt/
  - export PATH=$PATH:/opt/
  - pip install -r requirements.txt

  #  - export GECKO_DRIVER_VERSION='v0.31.0'
#  - wget https://github.com/mozilla/geckodriver/releases/download/$GECKO_DRIVER_VERSION/geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
#  - tar -xvzf geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
#  - rm geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
#  - chmod +x geckodriver
#  - cp geckodriver /usr/local/bin/

  # - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
  ##
  ## Run ssh-agent (inside the build environment)
  ##
  # - eval $(ssh-agent -s)
  ##
  ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  ## We're using tr to fix line endings which makes ed25519 keys work
  ## without extra base64 encoding.
  ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  ##
  # - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  - echo "$client_secret" > src/unlearn/client_secret.txt
  - echo "$client_id" > src/unlearn/client_id.txt
  - echo "$username" > src/unlearn/username.txt
  - echo "$password" > src/unlearn/password.txt

  - cat src/unlearn/client_secret.txt
  - cat src/unlearn/client_id.txt
  - cat src/unlearn/username.txt
  - cat src/unlearn/password.txt
  ##
  ## Create the SSH directory and give it the right permissions
  ##
  # - mkdir -p ~/.ssh
  # - chmod 700 ~/.ssh

pages:
  stage: deploy
  script:
    - pwd
    - cd src
    - xvfb-run -s "-screen 0 1400x900x24" python -m unlearn.tokenpage
#    - python -m unlearn.tokenpage
    - cd ..
    - ls
    - pwd
  artifacts:
    paths:
      - public

