name: Construct

on:
  push:
    paths:
        - 'index/**'

jobs:
  build:
    runs-on: docker

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

    - name: dependencies
      run: |
        apt-get update
        apt-get install -y openssl

    - name: setup env
      run: | 
        echo $PRIVATE_KEY64 | base64 --decode > private-key.pem
      env:
        PRIVATE_KEY64: ${{ secrets.PRIVATE_KEY64 }}

    - name: construct pkglists
      run: make
      env:
        AUTH_HOST: ${{ secrets.AUTH_HOST }}

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

    - uses: actions/forgejo-release@v2
      with:
        url: https://code.idtech.space
        repo: "pkg/lists"
        direction: upload
        release-dir: ./pkgs
        token: ${{ secrets.TOKEN }}
        override: true
