[GH-ISSUE #528] Issue: bash options don't match GitHub Actions #359

Closed
opened 2026-03-01 21:42:39 +03:00 by kerem · 0 comments
Owner

Originally created by @andrewgee on GitHub (Feb 12, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/528

Act version

act version 0.2.20

Expected behaviour

When providing a bash script in the run section of steps for a job, we expect the shell to be executed with the same options as GitHub Actions.

Actual behaviour

act runs with bash --noprofile --norc -eo pipefail {0}

GitHub Actions runs with /bin/bash -e {0}

The difference of pipefail is producing different behaviour when running our shell script with act locally.

Workflow and/or repository

Failing if the grep on line 41 fails:

workflow
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Clean

on: push

jobs:
  delete-artifacts:
    name: Delete Artifacts
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: Delete artifacts
        run: |
          # Customize those three lines with your repository and credentials:
          REPO=${GITHUB_API_URL}/repos/${{ github.repository }}

          # A shortcut to call GitHub API.
          ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }

          # A temporary file which receives HTTP response headers.
          TMPFILE=/tmp/tmp.$$

          # An associative array, key: artifact name, value: number of artifacts of that name.
          declare -A ARTCOUNT

          # Process all artifacts on this repository, loop on returned "pages".
          URL=$REPO/actions/artifacts
          while [[ -n "$URL" ]]; do

            # Get current page, get response headers in a temporary file.
            JSON=$(ghapi --dump-header $TMPFILE "$URL")

            # Get URL of next page. Will be empty if we are at the last page.
            URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
            rm -f $TMPFILE

            # Number of artifacts on this page:
            COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))

            # Loop on all artifacts on this page.
            for ((i=0; $i < $COUNT; i++)); do

              # Get name of artifact and count instances of this name.
              name=$(jq <<<$JSON -r ".artifacts[$i].name?")
              ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))

              id=$(jq <<<$JSON -r ".artifacts[$i].id?")
              size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
              printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
              ghapi -X DELETE $REPO/actions/artifacts/$id
            done
          done

Steps to reproduce

act -s GITHUB_TOKEN=..... -v

act output

Log
[Clean/Delete Artifacts               ]   ❌  Failure - Delete artifacts
DEBU[0001] exit with `FAILURE`: 1 
Originally created by @andrewgee on GitHub (Feb 12, 2021). Original GitHub issue: https://github.com/nektos/act/issues/528 ## Act version <!-- Paste output of `act --version` --> ```none act version 0.2.20 ``` ## Expected behaviour <!-- Describe how whole process should go and finish --> When providing a bash script in the `run` section of `steps` for a job, we expect the shell to be executed with the same options as GitHub Actions. ## Actual behaviour `act` runs with `bash --noprofile --norc -eo pipefail {0}` GitHub Actions runs with `/bin/bash -e {0}` The difference of `pipefail` is producing different behaviour when running our shell script with `act` locally. <!-- Describe what happened --> ## Workflow and/or repository Failing if the grep on line 41 fails: <details> <summary>workflow</summary> ```none # This file was automatically generated by sbt-github-actions using the # githubWorkflowGenerate task. You should add and commit this file to # your git repository. It goes without saying that you shouldn't edit # this file by hand! Instead, if you wish to make changes, you should # change your sbt build configuration to revise the workflow description # to meet your needs, then regenerate this file. name: Clean on: push jobs: delete-artifacts: name: Delete Artifacts runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Delete artifacts run: | # Customize those three lines with your repository and credentials: REPO=${GITHUB_API_URL}/repos/${{ github.repository }} # A shortcut to call GitHub API. ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } # A temporary file which receives HTTP response headers. TMPFILE=/tmp/tmp.$$ # An associative array, key: artifact name, value: number of artifacts of that name. declare -A ARTCOUNT # Process all artifacts on this repository, loop on returned "pages". URL=$REPO/actions/artifacts while [[ -n "$URL" ]]; do # Get current page, get response headers in a temporary file. JSON=$(ghapi --dump-header $TMPFILE "$URL") # Get URL of next page. Will be empty if we are at the last page. URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//') rm -f $TMPFILE # Number of artifacts on this page: COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) # Loop on all artifacts on this page. for ((i=0; $i < $COUNT; i++)); do # Get name of artifact and count instances of this name. name=$(jq <<<$JSON -r ".artifacts[$i].name?") ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) id=$(jq <<<$JSON -r ".artifacts[$i].id?") size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size ghapi -X DELETE $REPO/actions/artifacts/$id done done ``` </details> ## Steps to reproduce `act -s GITHUB_TOKEN=..... -v` ## `act` output <!-- Paste output from your terminal, use `-v` or `--verbose` for richer output --> <details> <summary>Log</summary> ```none [Clean/Delete Artifacts ] ❌ Failure - Delete artifacts DEBU[0001] exit with `FAILURE`: 1 ``` </details>
kerem 2026-03-01 21:42:39 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#359
No description provided.