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

Support repositories: ${{ github.repository }} #185

Open
MPV opened this issue Nov 13, 2024 · 3 comments
Open

Support repositories: ${{ github.repository }} #185

MPV opened this issue Nov 13, 2024 · 3 comments

Comments

@MPV
Copy link

MPV commented Nov 13, 2024

Could we please support passing (only) ${{ github.repository }} to the repositories input?

@MPV
Copy link
Author

MPV commented Nov 13, 2024

I've had to make use of this ugly workaround for now:

    steps:
      - name: Extract repo (only, not org) from ${{ github.repository }}
        id: repo
        run: |
          org_slash_repo="${{ github.repository }}"
          repo="${org_slash_repo##*/}"
          echo "repo=${repo}" >> "${GITHUB_OUTPUT}"
    
      - name: Create GitHub token for checking out ${{ github.repository }}
        uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
        id: app-token
        with:
          app-id: ${{ vars.MYORG_SOME_APP_ID }}
          private-key: ${{ secrets.MYORG_SOME_APP_PRIVATE_KEY }}
          owner: myorg
          repositories: ${{ steps.repo.outputs.repo }}
    
      - name: Checkout ${{ github.repository }}
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
        with:
          token: ${{ steps.app-token.outputs.token }}

But could we please add support for not needing it?

@MPV
Copy link
Author

MPV commented Nov 13, 2024

I've had to make use of this ugly workaround for now:
[...]
But could we please add support for not needing it?

Because when trying without it, like this:

    steps:
      - name: Create GitHub token for checking out ${{ github.repository }}
        uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
        id: app-token
        with:
          app-id: ${{ vars.MYORG_SOME_APP_ID }}
          private-key: ${{ secrets.MYORG_SOME_APP_PRIVATE_KEY }}
          owner: myorg
          repositories: ${{ github.repository }}

      - name: Checkout ${{ github.repository }}
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
        with:
          token: ${{ steps.app-token.outputs.token }}

I only get errors like this:

Failed to create token for "myorg/example-prototype-api" (attempt 2): Not Found - https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
Failed to create token for "myorg/example-prototype-api" (attempt 3): Not Found - https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
Failed to create token for "myorg/example-prototype-api" (attempt 4): Not Found - https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
RequestError [HttpError]: Not Found - https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
    at fetchWrapper (/home/runner/_work/_actions/actions/create-github-app-token/5d869da34e18e7287c1daad50e0b8ea0f506ce69/dist/main.cjs:37109:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async hook4 (/home/runner/_work/_actions/actions/create-github-app-token/5d869da34e[18](https://github.com/myorg/example-prototype-api/actions/runs/11816114724/job/32918724422?pr=73#step:2:18)e7287c1daad50e0b8ea0f506ce69/dist/main.cjs:39476:18)
    at async getTokenFromRepository (/home/runner/_work/_actions/actions/create-github-app-token/5d869da34e18e7287c1daad50e0b8ea0f506ce69/dist/main.cjs:39792:20)
    at async RetryOperation._fn (/home/runner/_work/_actions/actions/create-github-app-token/5d869da34e18e7287c1daad50e0b8ea0f506ce69/dist/main.cjs:39667:24) {
  status: 404,
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/myorg/myorg%2Fexample-prototype-api/installation',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/create-github-app-token',
      authorization: 'bearer [REDACTED]'
    },
    request: { hook: [Function: bound hook4] AsyncFunction }
  },

(note the duplicated myorg there in myorg/myorg/example-prototype-api)

@MPV
Copy link
Author

MPV commented Nov 13, 2024

This is especially interesting/needed nowadays when there is "Ruleset Workflows", which seem to require making use of actions/create-github-app-token since the GITHUB_TOKEN they use don't appear to have access to other repositories than the one the workflow is defined in (?).

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

1 participant