pin-github-action icon indicating copy to clipboard operation
pin-github-action copied to clipboard

Docker usage throws this error: Cannot find module '/src/bin.js'

Open evanstucker-hates-2fa opened this issue 10 months ago • 4 comments

$ alias pin-github-action="docker run --rm -v $(pwd):/src -e GH_ADMIN_TOKEN mheap/pin-github-action"
$ export GH_ADMIN_TOKEN=REDACTED
$ pin-github-action .github/workflows/docker-build-push.yml
Unable to find image 'mheap/pin-github-action:latest' locally
latest: Pulling from mheap/pin-github-action
1f3e46996e29: Pull complete 
11bcb6612b10: Pull complete 
e9a6e3e876c0: Pull complete 
40f144496201: Pull complete 
3628a6a42627: Pull complete 
5d07909e909f: Pull complete 
c52d65f7aaa6: Pull complete 
218d4db0784f: Pull complete 
Digest: sha256:beeb5d619eff9efbdd8e212f9c3a97c657dba80302d0f5aac37d5b8956d6b5bb
Status: Downloaded newer image for mheap/pin-github-action:latest
node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/src/bin.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.18.3

evanstucker-hates-2fa avatar Feb 19 '25 16:02 evanstucker-hates-2fa

Oh... so does npm usage:

$ sudo npm install -g pin-github-action
...
$ pin-github-action .github/workflows/docker-build-push.yml 
node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/src/bin.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.18.3

evanstucker-hates-2fa avatar Feb 19 '25 16:02 evanstucker-hates-2fa

Ah, the docker issue is because we are mapping $(pwd) over /src, so we can't see any files in the original /src in the docker image.

This works:

docker run --rm -it -v "$(pwd)/.github/workflows":/src/workflows mheap/pin-github-action /src/workflows

evanstucker-hates-2fa avatar Feb 19 '25 16:02 evanstucker-hates-2fa

This is strange as it works for me with the current setup (though I can see how it might not if we overwrite src).

❯ alias pin-github-action="docker run --rm -v $(pwd):/src -e GH_ADMIN_TOKEN mheap/pin-github-action"

❯ pin-github-action
Usage: pin-github-action [options] [file||directory ...]

Options:
  -V, --version           output the version number
  -a, --allow <actions>   comma separated list of actions to allow e.g.
                          mheap/debug-action. May be a glob e.g. mheap/*
  -i, --ignore-shas       do not update any commits that are pinned at a sha
  -e, --allow-empty       allow workflows that do not contain any actions
  -c, --comment <string>  comment to add inline when pinning an action
                          (default: " pin@{ref}")
  -h, --help              display help for command

❯ pin-github-action .github/workflows

❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   .github/workflows/ci.yml
	modified:   .github/workflows/release.yml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	bar.yaml
	foo.yaml

no changes added to commit (use "git add" and/or "git commit -a")

❯ git diff

Δ .github/workflows/ci.yml
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

────────────┐
• 13: jobs: │
────────────┘
    env:
      CI: true
    steps:
      - uses: actions/checkout@v4
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # pin@v4
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci

Are you using docker desktop?

mheap avatar Feb 24 '25 12:02 mheap

I'm on Arch Linux with regular docker, not Docker Desktop.

On Monday, February 24th, 2025 at 04:08, Michael Heap @.***> wrote:

mheap left a comment (mheap/pin-github-action#185)

This is strange as it works for me with the current setup (though I can see how it might not if we overwrite src).

❯ alias pin-github-action="docker run --rm -v $(pwd):/src -e GH_ADMIN_TOKEN mheap/pin-github-action"

❯ pin-github-action Usage: pin-github-action [options] [file||directory ...]

Options: -V, --version output the version number -a, --allow comma separated list of actions to allow e.g. mheap/debug-action. May be a glob e.g. mheap/* -i, --ignore-shas do not update any commits that are pinned at a sha -e, --allow-empty allow workflows that do not contain any actions -c, --comment comment to add inline when pinning an action (default: " pin@{ref}") -h, --help display help for command

❯ pin-github-action .github/workflows

❯ git status On branch main Your branch is up to date with 'origin/main'.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: .github/workflows/ci.yml modified: .github/workflows/release.yml

Untracked files: (use "git add ..." to include in what will be committed) bar.yaml foo.yaml

no changes added to commit (use "git add" and/or "git commit -a")

❯ git diff

Δ .github/workflows/ci.yml ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

────────────┐ • 13: jobs: │ ────────────┘ env: CI: true steps: - uses: @.*** - uses: @.*** # @.*** - name: Use Node.js ${{ matrix.node-version }} uses: @.*** uses: @.*** # @.*** with: node-version: ${{ matrix.node-version }} - run: npm ci

Are you using docker desktop?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

evanstucker-hates-2fa avatar Feb 24 '25 20:02 evanstucker-hates-2fa