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

Trigger workflow repo HTTP 404: Not Found #198

Closed
captainmoose opened this issue Nov 26, 2024 · 4 comments
Closed

Trigger workflow repo HTTP 404: Not Found #198

captainmoose opened this issue Nov 26, 2024 · 4 comments

Comments

@captainmoose
Copy link

captainmoose commented Nov 26, 2024

Hi again,

I am trying to do the same as in your example for Trigger a Workflow. I am getting the token but I am getting a 404, and I was wondering whether it is related to the token not being valid. Here is how the workflow looks like:

name: Trigger workflow

on:
  workflow_dispatch:
  push:
    branches:
      - main

permissions:
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: qoomon/actions--access-token@v3
        id: access-token
        with:
          permissions: |
            actions: write

      - name: Trigger workflow
        run: >-
          gh workflow
          run dockerpublish.yml
          --repo <my_org>/<target_repo>
          --ref main
          --field logLevel=debug
        env:
          GITHUB_TOKEN: ${{steps.access-token.outputs.token}}

The error I'm getting in GH Actions is:

Run gh workflow run dockerpublish.yml --repo <my_org>/<target_repo> --ref main --field logLevel=debug
HTTP 404: Not Found (https://api.github.com/repos/<my_org>/<target_repo>/actions/workflows/dockerpublish.yml)
Error: Process completed with exit code [1](https://github.com/<my_org>/<target_repo>/actions/runs/12034310818/job/33553492291#step:3:1).

I ran the gh workflow run dockerpublish.yml --repo <my_org>/<target_repo> --ref main from command prompt after a gh auth login and it ran fine.

@qoomon
Copy link
Owner

qoomon commented Nov 27, 2024

Is the target repo <my_org>/<target_repo> the same repository where the workflow you prodied runs in?

@qoomon
Copy link
Owner

qoomon commented Nov 27, 2024

If not you need to create a token for that target repository. By default a token for the repository of the workflow is requested.
So you might need to request the token for the target repository like this

     - uses: qoomon/actions--access-token@v3
        id: access-token
        with:
          repository: <my_org>/<target_repo>
          permissions: |
            actions: write

@captainmoose
Copy link
Author

Fixed. I was missing the correct subject in my access-token.yml file.

@qoomon
Copy link
Owner

qoomon commented Nov 27, 2024

Glad you could fix it, if you have any further question or ideas for improvements let me know

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

2 participants