name: Minecraft PC Assets Dumper

on:
  workflow_dispatch:
    inputs:
      minecraft-version:
        description: 'Version of minecraft to dump assets from'
        default: '1.16.5'
        required: true
        
jobs:
  dump-assets:
    runs-on: ubuntu-latest
    steps:
    - name: checkout
      uses: actions/checkout@v2
    - name: run tool
      run: npm i && node image_names.js ${{ github.event.inputs.minecraft-version }} out temp
    - name: upload to artifact
      uses: actions/upload-artifact@v2
      with:
        name: data
        path: out/${{ github.event.inputs.minecraft-version }}
  make-pr:
    runs-on: ubuntu-latest
    needs: dump-assets
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.PAT_PASSWORD }}
          repository: PrismarineJS/minecraft-assets
      - name: download from artifact
        uses: actions/download-artifact@v2.0.9
        with:
          name: data
          path: data/${{ github.event.inputs.minecraft-version }}/
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
            commit-message: Add data from ${{ github.event.inputs.minecraft-version }}
            title: Add data from ${{ github.event.inputs.minecraft-version }}
            body: |
              Auto-generated by a GH workflow
            branch: add-${{ github.event.inputs.minecraft-version }}-images
            token: ${{ secrets.PAT_PASSWORD }}
