name: Construct

on: push

jobs:
  build:
    runs-on: docker

    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 1

    - name: dependencies
      run: |
        apt update
        apt install -y \
        imagemagick wget

    - name: fteqw
      run: wget https://www.fteqw.org/dl/fteqw_linux64.zip && unzip fteqw_linux64.zip

    - name: setup env
      run: | 
        echo $PRIVATE_KEY > private-key.pem
        echo $PUBLIC_KEY > public-key.pem
      env:
        PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
        PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}

    - name: construct pkglists
      run: make && rm private-key.pem public-key.pem
      env:
        AUTH_HOST: ${{ secrets.AUTH_HOST }}

    - uses: actions/upload-artifact@v3
      with:
        name: pkg-lists
        path: pkgs/*.txt
