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

Get repository, ref via Github API #124

Open
ianlewis opened this issue May 30, 2022 · 7 comments
Open

Get repository, ref via Github API #124

ianlewis opened this issue May 30, 2022 · 7 comments
Labels
area:detect-workflow Issue with the detect-workflow Github action area:library Issue with the base reusable Go library status:help wanted Extra attention is needed type:refactor A cleanup or refactor

Comments

@ianlewis
Copy link
Member

ianlewis commented May 30, 2022

Currently we have to have special case code to run e2e tests in pull requests due to #131. I'd like to get rid of that code so that pull requests run normally.

I want to see if I can't get the repository and ref via the Github API rather than by creating an OIDC token. Creating an OIDC token requires id-token scope which is not normally given to workflows triggered by the pull_request event.

This wouldn't allow us to sign using sigstore's Github provider, but it would at least solve the problem of getting the reusable workflow repo and ref.

@ianlewis ianlewis added type:feature New feature or request area:detect-workflow Issue with the detect-workflow Github action labels May 30, 2022
@ianlewis ianlewis self-assigned this May 30, 2022
@ianlewis ianlewis added the area:library Issue with the base reusable Go library label May 30, 2022
@laurentsimon
Copy link
Collaborator

This was done and can be closed?

@ianlewis ianlewis added type:refactor A cleanup or refactor and removed type:feature New feature or request labels Jun 29, 2022
@ianlewis ianlewis removed their assignment Jun 29, 2022
@ianlewis
Copy link
Member Author

No, this is just an idea I had that I wanted to get the repo and ref via the GitHub API instead of by using job_workflow_ref an OIDC token. I'm not sure it's really possible. It's more of a refactor than a feature and it's not really high priority.

@laurentsimon
Copy link
Collaborator

ho right, my bad.

@asraa
Copy link
Collaborator

asraa commented Mar 1, 2023

Update here: detect-workflow-js works this way so the remaining item here is to (after ensuring some stability in that new action) to deprecate detect-workflow and replace with detect-workflow-js

@ianlewis
Copy link
Member Author

The old detect-workflow action was removed in #1988 and detect-workflow-js does this already. Closing.

if (
process.env.ACTIONS_ID_TOKEN_REQUEST_URL &&
process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN &&
process.env.GITHUB_EVENT_NAME !== "pull_request" &&
process.env.GITHUB_EVENT_NAME !== "merge_group"
) {
// Use the OIDC token when available.
const aud = path.join(repoName, "detect-workflow-js");
[repository, ref, workflow] = await detectWorkflowFromOIDC(aud);
} else {
// Otherwise, try to use the referenced workflows from the current workflow run.
core.info(
"Failed to retrieve OIDC token. This may be due to missing id-token: write permissions.",
);
[repository, ref, workflow] = await detectWorkflowFromContext(
repoName,
token,
);
}

@github-actions github-actions bot reopened this May 18, 2024
Copy link

This issue was reopened by the todo-issue-reopener action in the "TODO Issue Reopener" GitHub Actions workflow because there are TODOs referencing this issue:

  1. internal/builders/container/generate.go:55: Remove
  2. internal/builders/container/generate.go:63: Remove
  3. internal/builders/generic/attest.go:87: Remove
  4. internal/builders/generic/attest.go:95: Remove
  5. internal/builders/go/pkg/provenance.go:129: Remove
  6. internal/builders/go/pkg/provenance.go:139: Remove
  7. internal/builders/go/pkg/provenance_test.go:26: Remove

@ianlewis
Copy link
Member Author

So I think the issue is that this is fixed for detect-workflow-js but we only use that for our pre-BYOB builders/generators that were written in Go in order to detect which repo/ref to checkout in order to build the builder binary for pre-submits/e2e tests.

We still need to update the pre-BYOB builder code itself to clean up how we deal with pre-submits and e2e tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:detect-workflow Issue with the detect-workflow Github action area:library Issue with the base reusable Go library status:help wanted Extra attention is needed type:refactor A cleanup or refactor
Projects
None yet
Development

No branches or pull requests

3 participants