act icon indicating copy to clipboard operation
act copied to clipboard

actions/checkout fails `with:` `ref: ${{ github.event.pull_request.head.sha }}` with un-pushed commits

Open brianjmurrell opened this issue 1 year ago • 6 comments
trafficstars

Bug report info

act version:            0.2.64
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 12
Docker host:            unix:///run/user/1001/podman/podman.sock
Sockets found:
        /var/run/docker.sock(broken)
        $XDG_RUNTIME_DIR/podman/podman.sock
Config files:           
        /home/brian/.config/act/actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.22.4
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -buildmode:           pie
                -compiler:            gc
                -trimpath:            true
                DefaultGODEBUG:       httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
                CGO_ENABLED:          1
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
Docker Engine:
        Engine version:        5.1.1
        Engine runtime:        crun
        Cgroup version:        2
        Cgroup driver:         systemd
        Storage driver:        overlay
        Registry URI:          
        OS:                    fedora
        OS type:               linux
        OS version:            40
        OS arch:               amd64
        OS kernel:             6.9.6-200.fc40.x86_64
        OS CPU:                12
        OS memory:             63943 MB
        Security options:
                name=seccomp,profile=default
                name=rootless
                name=selinux

Command used with act

act

Describe issue

It appears that act does some kind of override when it encounters:

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

where it copies the local directory to where the workflow is being run:

[Linting/ShellCheck] ⭐ Run Main Checkout code
[Linting/ShellCheck]   🐳  docker cp src=/foo/actions-lib/. dst=/foo/actions-lib
[Linting/ShellCheck]   ✅  Success - Main Checkout code

This seems reasonable/

This override does not seem to happen though when one adds:

        with:
          ref: ${{ github.event.pull_request.head.sha }}

to the actions/checkout step.

While it seems reasonable not to invoke the override when one specifies a ref:, I think when the ref is ${{ github.event.pull_request.head.sha }}, one expects the job to act on the current directory the same as if the ref: was not specified.

Link to GitHub repository

No response

Workflow content

name: Linting

# Always run on Pull Requests as then these checks can be marked as required.
on:
  push:
    branches:
      - master
  pull_request:

permissions: {}

jobs:
  shell-check:
    name: ShellCheck
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Add error parser
        run: echo -n "::add-matcher::shellcheck-matcher.json"
      - name: Run ShellCheck
        uses: ludeeus/[email protected]
        with:
          format: gcc

  linting-summary:
    name: Linting Summary
    runs-on: ubuntu-22.04
    needs: [shell-check]
    if: (!cancelled())
    steps:
      - name: Check if any job failed
        run: |
          if [[ -z "$(echo "${{ join(needs.*.result, '') }}" | sed -e 's/success//g')" ]]; then
            echo "All jobs succeeded"
          else
            echo "One or more jobs did not succeed"
            exit 1
          fi

Relevant log output

I suspect this is not really necessary.  If it is, I can add it.

Additional information

No response

brianjmurrell avatar Jul 09 '24 20:07 brianjmurrell