ComunidadAylas/PackSquash-action

Add more workflow examples and consider creating a template repository

AlexTMjugador opened this issue · 7 comments

In the original repositories that sparkled development of this action, @sya-ri included a workflow that created a release on each push, which I think is a nice use for the action: https://github.com/sya-ri/action-PackSquash-Example

Some anecdotal evidence also suggests that downloading the artifact this action generates to do something with it, especially deploying it over SSH, is also pretty common.

Thus, the readme can be improved by including example workflows for those two scenarios.

There was also a template repository for the GitHub Action, that might be useful to get started quickly with it: https://github.com/sya-ri/action-PackSquash-Template

Some anecdotal evidence also suggests that downloading the artifact this action generates to do something with it, especially deploying it over SSH, is also pretty common.

Minecraft resource pack loading:

  1. The server sends you a URL and hash(pack)
  2. Hash the URL
  3. Download if no pack matches the hash(url)
  4. Test if the hash(pack) sent by the server matches the pack hash

You should not use different packs if they have the same URL. Therefore, it is better to deploy in a different workflow or as pack-{version tag}.zip.


For example:

⚠️ Pack directory is pack/.

packsquash.yml

name: Optimize Resource Pack
on:
  push:
    paths:
      - 'pack/**'
      - '.github/workflows/packsquash.yml'
jobs:
  packsquash:
    runs-on: ubuntu-latest
    steps:
      - name: Clone Repository
        uses: actions/checkout@master
        with:
          fetch-depth: 0
      - name: Run PackSquash
        uses: ComunidadAylas/PackSquash-action@v2
        with:
          path: pack
      - name: Download Optimize Pack
        uses: actions/download-artifact@v2
        with:
          name: Optimized pack
      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: action-v${{ github.run_number }}
          files: |
            pack.zip

deploy.yml

name: Deploy
on:
  workflow_dispatch:
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Download pack.zip
        uses: dsaltares/fetch-gh-release-asset@master
        with:
          file: "pack.zip"
          target: "pack.zip"
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Rename file
        run: "mv pack.zip pack-${{ github.run_number }}.zip"
      - name: Upload pack.zip
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: ${{ secrets.SSH_PORT }}
          source: "pack-${{ github.run_number }}.zip"
          target: ${{ secrets.DEPLOY_DIRECTORY }}
      - name: Output pazk.zip name
        run: echo "::notice::pack-${{ github.run_number }}.zip"

Create a release every time push. All commits are release commits.

Thank you so much for the example workflow! I can't add it right now to the readme (it's pretty late here), but we could do that at some point. Feel free to do so if you want to 👍

Also, as a template repository for PackSquash-action, there is https://github.com/sya-ri/MinecraftResourcePackTemplate (in Japanese).

Use apply.sh or apply.bat to automatically commit and push. Explains how to add resource packs (for development) using symbolic links.

Do you need a template repository? You can close this issue if you don't need it. I don't think it's necessary to create it officially because there're many use cases.
However, I think that if you write a list of template repositories, users freely create PR and can add one self-made. What do you think?

I think there is still some value in creating template repositories, but the README examples expansion and improvement rendered it less necessary. Moreover, I agree that there are many use cases, and if there was a single official template repository, users will likely need to tweak it anyway to satisfy their needs.

The idea of maintaining a list of community-provided template repositories sounds great to me and would render an official template repository unnecessary. It would also let us gain more insight into how people use PackSquash, and be a nice opportunity for first-time contributors. I'm all for it ❤️

I'll add a section in the README with links to templates and then close this issue. @osfanbuff63, excuse the random mention, but would you like your minecraft-datapack template to be featured on such a list?

It's also good to add flows to CONTRIBUTION.md and create a PR template. It's developer-friendly!

@osfanbuff63, excuse the random mention, but would you like your minecraft-datapack template to be featured on such a list?

If you'd like to put that template there, I'd be happy with that! Momentarily, I forgot I used this action there, but it makes sense. :D