Skip to content
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

Error Mapping Token when using Github workflows reusable #160

Closed
EzzioMoreira opened this issue Jul 24, 2022 · 2 comments
Closed

Error Mapping Token when using Github workflows reusable #160

EzzioMoreira opened this issue Jul 24, 2022 · 2 comments

Comments

@EzzioMoreira
Copy link

Hi all, I'm trying to create a reusable workflow from GitHub actions using actions/add-to-project. The problem is that it returns an error when parsing secrets A mapping was not expected Unexpected type 'MappingToken' encountered while reading 'input value'. The 'StringToken' type was expected.
This is my code:

Reusable flow:

name: "Adiciona Issues em Projects GitHub"

on:
  workflow_call:
    inputs:
      project_url:
        description: "URL do projetcs github"
        required: true
        type: string
    secrets:
      token:
        description: "Personal token para leitura/escrita projects github"
        required: true

jobs:
  add-to-project:
    name: Add issue to project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/add-to-project@main
        with:
          project-url: {{ inputs.project_url }}
          github-token: ${{ secrets.token }}

Reusable actions call:

name: "Adiciona Issues em Projects GitHub"
  
on:
  issues:
    types:
      - opened

jobs:
  add-issue:
    uses: "EzzioMoreira/lab-actions/.github/workflows/add-projects.yaml@master"
    with:
      project_url: https://github.com/users/EzzioMoreira/projects/2
    secrets:
      token: ${{ secrets.API_TOKEN_GITHUB }}

I tried using another realize tag but always returned the error The 'StringToken' type was expected.
I think that my code is correct.
Has anyone else reported any problem?

@camchenry
Copy link
Contributor

👋 @EzzioMoreira I was able to reproduce this issue in a test organization + repository. The error seems to indicate that the issue is with this line in the add-projects.yaml:

jobs:
  add-to-project:
    name: Add issue to project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/add-to-project@main
        with:
          project-url: {{ inputs.project_url }} # Error: A mapping was not expected Unexpected type 'MappingToken' encountered while reading 'inputs value'. The type 'StringToken' was expected.
          github-token: ${{ secrets.token }}

I was able to fix this error by interpolating the input value using ${{ instead of just {{:

jobs:
  add-to-project:
    name: Add issue to project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/add-to-project@main
        with:
          project-url: ${{ inputs.project_url }}
          github-token: ${{ secrets.token }}

Please try this and let me know if you are still having issues. If there is still an error, it would be helpful to include the full stack trace of the error as well. Thank you!

@hussam-i-am
Copy link

@EzzioMoreira just wanted to check in and see if this has been resolved, if so, will close this out

@mattcosta7 mattcosta7 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants