s0 / git-publish-subdir-action

GitHub Action to push a subdirectory as a branch to any git repo (e.g. for GitHub Pages)
https://github.com/marketplace/actions/push-git-subdirectory-as-branch
MIT License
203 stars 33 forks source link

Cannot read property 'slice' of null #71

Open jorgev259 opened 2 years ago

jorgev259 commented 2 years ago

Run s0/git-publish-subdir-action@develop

TypeError: Cannot read property 'slice' of null at GitPackIndex.readSlice (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:20962:35) at async readObjectPacked (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:21079:22) at async _readObject (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:21121:14) at async resolveCommit (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:28643:28) at async _readCommit (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:28670:38) at async _log (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:28805:17) at async Object.log (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:28973:12) at async getGitInformation (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:12804:24) at async main (/home/runner/work/_actions/s0/git-publish-subdir-action/develop/action/dist/index.js:12823:21) { caller: 'git.log' }

The workflow file being used is https://github.com/jorgev259/silentwalker_gallery_rework/blob/main/.github/workflows/build-gh-pages.yml

laszlo-san commented 1 year ago

We managed to work around this by createing a simple bash script, this is not a bugfix for this repo tough.

We crated a push.sh file with content:

#!/bin/bash
# process flags (WARNING: no error handling if not provided!)
while getopts b:f:m: flag
do
    case "${flag}" in
        b) branch=${OPTARG};;
        f) folder=${OPTARG};;
        m) message=${OPTARG};;
    esac
done

# git setup
git --version;
git config user.name "GitHub Actions Bot";
git config user.email "<>";

# get the last commit basic data
hash=$(git log -1 --pretty=%h);
old_subject=$(git log -1 --pretty=%s);

find -maxdepth 1 -mindepth 1 -type d,f -regextype posix-egrep -not -regex "./($folder.{0,}|.git|.git/.{0,})" -exec rm -rf "{}" +;
mv ./"$folder"/* .;
rm -rf ./"$folder"/;
git fetch --all;
git switch -C temporary;
git add -A;
git commit -m "Temporary commit";
git checkout -B "$branch";
git reset --hard origin/"$branch";
git checkout temporary ./;
git add -A;
git commit -m "($hash) $old_subject" -m "$message";
git push origin "$branch";

and modified the action like this:

name: Generate a build and push to build branch

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build and Push
    steps:
      - name: Use Node.js 16
        uses: actions/setup-node@v1
        with:
          node-version: 16

      - name: git-checkout
        uses: actions/checkout@v2

      - name: Run build script
        run: ./gh-action-build.sh

      - name: Push to Build
        shell: bash
        run: ./push.sh -b build -f build -m "Automated build"
zwippie commented 1 year ago

@laszlo-san Just had the exact same error while deploying. Do you have any pointers to why this is happening?

laszlo-san commented 1 year ago

@zwippie The action script uses an older node version, or Github gives different properties now to actions and this repo does not updated accordingly? Can't really tell. In any case we could not go deeper or had the time to debug, hence we had to implement a different aproach.