Skip to content

Action step with git authentication fails inside workflow_call when needs is set #31900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
javiertury opened this issue Aug 22, 2024 · 3 comments
Labels
topic/gitea-actions related to the actions of Gitea type/bug

Comments

@javiertury
Copy link

Description

Doing a git checkout (actions/checkout@v4) inside a workflow_call that needs another job raises an authentication error.

It can be reproduced using the following nested workflow.

Workflow to reproduce the error
# .gitea/workflows/main.yaml
name: test
run-name: test

on:
  workflow_dispatch:
  push:
    branches:
      - main


jobs:
  foo:
    runs-on: ubuntu-latest
    steps:
      -
        name: Foo
        run: |
          echo 'foo: ${{ inputs.foo }}'

  # Works fine, even if it has a dependency
  outer_needy_checkout:
    runs-on: ubuntu-latest
    needs: [foo]
    steps:
      -
        name: Outer needy checkout
        uses: https://github.com/actions/checkout@v4

  nested_checkout:
    runs-on: ubuntu-latest
    uses: ./.gitea/workflows/nested-checkout.yaml
    with:
      foo: bar
    secrets: inherit

  nested_needy_checkout:
    runs-on: ubuntu-latest
    uses: ./.gitea/workflows/nested-checkout.yaml
    needs: [foo]
    with:
      foo: bar
    secrets: inherit
# .git/workflows/nested-checkout.yaml

name: nested git checkout
run-name: nested git checkout
on:
  workflow_call:
    inputs:
      foo:
        type: string
        required: false

jobs:
  foo:
    runs-on: ubuntu-latest
    steps:
      -
        name: Foo
        run: |
          echo 'foo: ${{ inputs.foo }}'
      # This checkout works fine too, even though we are in a workflow_call
      -
        name: Nested checkout
        uses: https://github.com/actions/checkout@v4

  # fatal: could not read Username for '<repo>': terminal prompts disabled
  inner_needy_checkout:
    runs-on: ubuntu-latest
    needs: [foo]
    steps:
      -
        name: Nested needy checkout
        uses: https://github.com/actions/checkout@v4

The step Nested needy checkout fails with

fatal: could not read Username for '<repo>': terminal prompts disabled

Bear in mind that due to bugs #26736 and #26187, the UI marks the job as a sucess, but reading the logs in details reveals the error.

Gitea Version

1.22.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image

Git Version

No response

Operating System

No response

How are you running Gitea?

I'm using the official gitea helm chart on k3s

Database

SQLite

@yp05327 yp05327 added the topic/gitea-actions related to the actions of Gitea label Aug 22, 2024
@Zettat123
Copy link
Contributor

This bug is not related to needs. Actually, this bug can be reproduced without needs, but not stably. The reason should be that Gitea does not correctly handle reusable workflows with multiple jobs.

@lunny
Copy link
Member

lunny commented Sep 24, 2024

This should be fixed by https://gitea.com/gitea/act/pulls/116

chhe pushed a commit to chhe/act that referenced this issue Sep 26, 2024
Fix [#31900](go-gitea/gitea#31900)

Reviewed-on: https://gitea.com/gitea/act/pulls/116
Reviewed-by: Jason Song <[email protected]>
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: Zettat123 <[email protected]>
Co-committed-by: Zettat123 <[email protected]>
@WereCatf
Copy link

This should be fixed by https://gitea.com/gitea/act/pulls/116

Um, no, it's not. I just ran into this issue myself and authentication still fails with the "could not read Username for" message. Given that the issue is not fixed, I don't understand why this was closed.

@lunny lunny reopened this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

No branches or pull requests

5 participants