[GH-ISSUE #2400] github.event.repository.default_branch is wrong #1103

Open
opened 2026-03-01 21:48:55 +03:00 by kerem · 3 comments
Owner

Originally created by @cwrau on GitHub (Jul 17, 2024).
Original GitHub issue: https://github.com/nektos/act/issues/2400

Bug report info

act version:            0.2.63
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	$XDG_RUNTIME_DIR/podman/podman.sock
Config files:           
	/home/cwr/.config/act/actrc:
		-P ubuntu-latest=catthehacker/ubuntu:full-latest
		-P ubuntu-22.04=catthehacker/ubuntu:full-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:full-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:full-18.04
Build info:
	Go version:            go1.22.3
	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

Command used with act

act -j getChangedCharts -v

Describe issue

I expected to see my workflow to run like it would on github itself.

But github.event.repository.default_branch evaluated to master instead of main;

expression 'format('{0}', github.event.pull_request.base.ref || github.event.repository.default_branch)' evaluated to '%!t(string=master)'

https://github.com/teutonet/teutonet-helm-charts

Workflow content

name: Get changed charts in last commit

on:
  workflow_call:
    outputs:
      charts:
        description: The names of the changed charts in the last commit
        value: ${{ jobs.getChangedCharts.outputs.charts }}

jobs:
  getChangedCharts:
    runs-on: ubuntu-22.04
    outputs:
      charts: ${{ steps.getCharts.outputs.charts }}
    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

      - name: Get all charts
        id: getCharts
        env:
          CT_TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }}
        run: |
          set -ex
          set -o pipefail
          (
            echo -n charts=
            ct list-changed | cut -d / -f 2 | jq -c -Rn '[inputs]'
          ) | tee -a "$GITHUB_OUTPUT"

Relevant log output

expression 'format('{0}', github.event.pull_request.base.ref || github.event.repository.default_branch)' evaluated to '%!t(string=master)'

Additional information

No response

Originally created by @cwrau on GitHub (Jul 17, 2024). Original GitHub issue: https://github.com/nektos/act/issues/2400 ### Bug report info ```plain text act version: 0.2.63 GOOS: linux GOARCH: amd64 NumCPU: 16 Docker host: DOCKER_HOST environment variable is not set Sockets found: $XDG_RUNTIME_DIR/podman/podman.sock Config files: /home/cwr/.config/act/actrc: -P ubuntu-latest=catthehacker/ubuntu:full-latest -P ubuntu-22.04=catthehacker/ubuntu:full-22.04 -P ubuntu-20.04=catthehacker/ubuntu:full-20.04 -P ubuntu-18.04=catthehacker/ubuntu:full-18.04 Build info: Go version: go1.22.3 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 ``` ### Command used with act ```sh act -j getChangedCharts -v ``` ### Describe issue I expected to see my workflow to run like it would on github itself. But `github.event.repository.default_branch` evaluated to `master` instead of `main`; ``` expression 'format('{0}', github.event.pull_request.base.ref || github.event.repository.default_branch)' evaluated to '%!t(string=master)' ``` ### Link to GitHub repository https://github.com/teutonet/teutonet-helm-charts ### Workflow content ```yml name: Get changed charts in last commit on: workflow_call: outputs: charts: description: The names of the changed charts in the last commit value: ${{ jobs.getChangedCharts.outputs.charts }} jobs: getChangedCharts: runs-on: ubuntu-22.04 outputs: charts: ${{ steps.getCharts.outputs.charts }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1 - name: Get all charts id: getCharts env: CT_TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }} run: | set -ex set -o pipefail ( echo -n charts= ct list-changed | cut -d / -f 2 | jq -c -Rn '[inputs]' ) | tee -a "$GITHUB_OUTPUT" ``` ### Relevant log output ```sh expression 'format('{0}', github.event.pull_request.base.ref || github.event.repository.default_branch)' evaluated to '%!t(string=master)' ``` ### Additional information _No response_
Author
Owner

@github-actions[bot] commented on GitHub (Jan 14, 2025):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:2588484040 --> @github-actions[bot] commented on GitHub (Jan 14, 2025): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@bryansan commented on GitHub (Jan 14, 2025):

ping

<!-- gh-comment-id:2590599183 --> @bryansan commented on GitHub (Jan 14, 2025): ping
Author
Owner

@ChristopherMacGown commented on GitHub (Jun 23, 2025):

The act command has a --defaultbranch parameter that when set will apply your default branch.

<!-- gh-comment-id:2998078120 --> @ChristopherMacGown commented on GitHub (Jun 23, 2025): The `act` command has a `--defaultbranch` parameter that when set will apply your default branch.
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#1103
No description provided.