ad-m / github-push-action

GitHub actions to push back to repository eg. updated code
MIT License
1.21k stars 230 forks source link

Push error - require is not defined in ES module scope #157

Closed jiyoonlim123 closed 1 year ago

jiyoonlim123 commented 1 year ago

This is my workflow app, but it shows following errors.

      - name: Push changes
        if: |
          steps.docker-files-changed.outputs.any_changed == 'true' && steps.helm-files-changed.outputs.any_changed == 'false'
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}
image
ZPascal commented 1 year ago

Hi @jiyoonlim123, I need a bit more information from your side to further debug the case. Could you please forward the complete action file, especially the runs-on part? Is it a GTE instance or public GitHub? Is the repository public available?

jiyoonlim123 commented 1 year ago

I delete some confidential code. It is the private GitHub and I set the push permission to the GitHub token.

    runs-on: [self-hosted]

    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
          submodules: recursive
          token: ${{ secrets.ORG_PAT }}

    - name: Update and image version
        id: update-image-version-tag
        run: |
          python hooks/update_image_tag.py

      - name: Commit changed files
        run: |
          git config user.email <USEREMAIL>
          git config user.name <USERNAME>
          git add .
          git status
          git commit -m "bump version to ${{ steps.update-image-version-tag.outputs.image_name }}"
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}
ZPascal commented 1 year ago

@jiyoonlim123 Which image do you are using for the runner? Is it Ubuntu?

jiyoonlim123 commented 1 year ago

@jiyoonlim123 Which image do you are using for the runner? Is it Ubuntu?

Yes we use Ubuntu 18.04

ZPascal commented 1 year ago

@jiyoonlim123 I think the issue is related to the used Node.js version. I can prepare a PR to create a package.json, but first I want to reproduce the case. As a workaround, I recommend using the setup-node action beforehand and use Node.js version 18 (I'm personally using and testing with Ubuntu 22.04, Node.js → v18). BTW: The community support of Ubuntu 18.04 Bionic will be removed end of April. I've also identified, that the community updated the Node.js version a few days ago inside the runner repository of Ubuntu 18.04 to a new minor version. That could be the reason why it's now not possible anymore to use the action.

jiyoonlim123 commented 1 year ago

Thanks for your help!! I think your opinion is right since I can see some nodejs version warning in the github action log. As you said, I will update the nodejs version.

ZPascal commented 1 year ago

That's great. If that solves your problem, please close this issue. Thank you.