diff --git a/.github/workflows/refresh-modpack.yml b/.github/workflows/refresh-modpack.yml new file mode 100644 index 0000000..7aad55b --- /dev/null +++ b/.github/workflows/refresh-modpack.yml @@ -0,0 +1,62 @@ +name: Refresh Modpack File Index +on: + push: + branches: + - main + pull_request_target: + types: + - opened + - synchronize + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + refresh-modpack: + name: Refresh Modpack ${{ matrix.modpack }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + strategy: + matrix: + modpack: + - forgeworks + steps: + - name: Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + fetch-depth: 0 + - name: Install Dependencies + uses: ./.github/actions/install-yarn-dependencies + with: + node-version: 22 + - name: Install nix + uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31 + - name: Configure Git + run: | + git remote set-url origin "https://${GITHUB_TOKEN}:x-oauth-basic@github.com/${GITHUB_REPOSITORY}.git" + git config --local user.email "${GITHUB_EMAIL}" + git config --local user.name "${GITHUB_USER}" + env: + GITHUB_USER: github-actions[bot] + GITHUB_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build + run: yarn build + - name: Refresh Modpack + working-directory: packages/${{ matrix.modpack }}/modpack + run: nix develop --command packwiz refresh + - name: Commit Changes and Push + run: | + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "chore(${{ matrix.modpack }}): refresh index" + git pull --rebase origin ${{ github.head_ref || 'main' }} + git push origin HEAD:${{ github.head_ref || 'main' }} + else + echo "No changes to commit." + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}