Home > Net >  github actions' parameter passing problem
github actions' parameter passing problem

Time:01-19

I encountered a problem when I passed the repository path from A workflow to B workflow, and the value was not passed correctly in checkout actions.

A workflow

jobs:

  Reuse:
    uses: org/repo/.github/workflows/b_workflow.yml
    with:
      enviroment_name: SANDBOX
      repo_name: $GITHUB_REPOSITORY
    secrets: 
      token: ${{ secrets.SOURCE_REPO_TOKEN }}

B workflow

on:
  workflow_call:
    inputs:
      repo_name:
        type: string
        required: true
        description: "REPO Name"

  build:
    runs-on: ubuntu-latest
    environment:
      name: CRM
    steps:
      - uses: actions/checkout@v3
        with:
          repository: ${{ inputs.repo_name }}
          ref: test
          token: ${{ secrets.token }}
          path: source

Output

Run actions/checkout@v3
  with:
    repository: $GITHUB_REPOSITORY
    ref: test
    token: ***
    path: source
    ssh-strict: true
    persist-credentials: true
    clean: true
    fetch-depth: 1
    lfs: false
    submodules: false
    set-safe-directory: true
Error: Invalid repository '$GITHUB_REPOSITORY'. Expected format {owner}/{repo}.

I checked the documentation of github actions, but I didn't find a syntax problem. How should I pass the correct value to the “repository:”?

CodePudding user response:

I solved the problem myself by modifying A flow to the following and it was fine.

A workflow

jobs:

  Reuse:
    uses: org/repo/.github/workflows/b_workflow.yml
    with:
      enviroment_name: SANDBOX
      repo_name: ${{ github.REPOSITORY }}
    secrets: 
      token: ${{ secrets.SOURCE_REPO_TOKEN }}
  • Related