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

Check and update dependencies in GitHub Actions action.yml #4178

Closed
slawekjaranowski opened this issue Aug 30, 2021 · 34 comments · Fixed by #4755
Closed

Check and update dependencies in GitHub Actions action.yml #4178

slawekjaranowski opened this issue Aug 30, 2021 · 34 comments · Fixed by #4755
Labels
L: github:actions GitHub Actions T: feature-request Requests for new features

Comments

@slawekjaranowski
Copy link
Contributor

When using composite actions steps are defined in action.yml and we can have dependency to another actions.

Currently dependencies aren't checked in action.yml

@slawekjaranowski slawekjaranowski added the T: feature-request Requests for new features label Aug 30, 2021
@georgettica
Copy link

This issue infers there is already partial support for dependency update for github-actions.. can you direct me to docs on that?

@localheinz

This comment was marked as duplicate.

jurre pushed a commit to JonasAlfredsson/dependabot-core that referenced this issue Mar 8, 2022
Composite Actions follow a very similar structure to the "normal"
GitHub Actions, with the exception that they must be located in a
file called action.yml (or .yaml) in the root of the repository.

Because of this similarity the file_parser and the file_updater does
not need any tweaking, and it is only the file_fetcher that needs to
be able to search beyond the .github/workflows folder.

Since GitHub only looks for a single file in the root directory of
the repository we can limit the expansion to the search to the same
strict parameters so we don't accidentally find a lot of other stuff.

Resolves dependabot#4178
@georgettica
Copy link

@localheinz by the commits and closing of the issue, this seems to be done
@jurre LMK if there is something missing on this

@briantist
Copy link

briantist commented Mar 8, 2022

@georgettica composite actions (all actions I think) do not have to be in the root of the repository, and a repository may contain multiple actions.

An action can be referenced like uses: org/repo/directory/otherdir/action-name@v1 for example.

Composite actions in the same repo can also be referenced as local files, uses: ./my-action/otherdir/action-name

Does the given PR handle those? It seems to make assumptions about the location of the action.yml

@Pwd9000-ML
Copy link

@georgettica
I don't think this is working.
I just tried to set up a dependabot scan on my composite action and got the following:

image

Log:
proxy | time="2022-03-08T16:45:07Z" level=info msg="proxy starting" commit=0cfe6fc8a85a641097e4d9faf5c8349b892b1e40
proxy | 2022/03/08 16:45:07 Listening (:1080)
updater | 2022-03-08T16:45:08.039941890 [anonymous-instance:main:WARN:src/firecracker/src/main.rs:370] You are using a deprecated parameter: --seccomp-level 2, that will be removed in a future version.
updater | 2022-03-08T16:45:08.064913447 [311503392:main:WARN:src/devices/src/legacy/serial.rs:432] Detached the serial input due to peer close/error.
updater | time="2022-03-08T16:45:09Z" level=info msg="guest starting" commit=a5729a532c883b4e3cd2f515bc51b56439833597
updater | time="2022-03-08T16:45:09Z" level=info msg="starting job..." fetcher_timeout=5m0s job_id=311503392 updater_timeout=45m0s updater_version=0.177.0-e249ab4d30a55fc1669c68134e7f7cc3074f4325
updater | I, [2022-03-08T16:45:10.979830 #7] INFO -- sentry: ** [Raven] Raven 3.1.2 ready to catch errors
updater | INFO <job_311503392> Starting job processing
proxy | 2022/03/08 16:45:13 [002] GET https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate
proxy | 2022/03/08 16:45:13 [002] * authenticating github api request
proxy | 2022/03/08 16:45:13 [002] 200 https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate
proxy | 2022/03/08 16:45:13 [004] GET https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate/git/refs/heads/master
proxy | 2022/03/08 16:45:13 [004] * authenticating github api request
proxy | 2022/03/08 16:45:13 [004] 200 https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate/git/refs/heads/master
proxy | 2022/03/08 16:45:13 [006] GET https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate/contents/.github/workflows?ref=bafcb2169a6a00bcafc4226108d232625e9bbf6b
proxy | 2022/03/08 16:45:13 [006] * authenticating github api request
proxy | 2022/03/08 16:45:13 [006] 404 https://api.github.com:443/repos/Pwd9000-ML/azure-vm-password-rotate/contents/.github/workflows?ref=bafcb2169a6a00bcafc4226108d232625e9bbf6b
updater | ERROR <job_311503392> Error during file fetching; aborting
updater | INFO <job_311503392> Finished job processing
updater | INFO Results:
updater | Dependabot encountered '1' error(s) during execution, please check the logs for more details.
updater | time="2022-03-08T16:45:13Z" level=info msg="task complete" container_id=job-311503392-file-fetcher exit_code=0 job_id=311503392 step=fetcher
updater | time="2022-03-08T16:45:13Z" level=warning msg="failed during fetch, skipping updater" job_id=311503392

action.yml location is at root of repo:
image

code snippet of dependabot.yml

version: 2
updates:
  - package-ecosystem: "github-actions" # search for actions - there are other options available
    directory: "/" # search in .github/workflows under root `/` or action.yml at root
    schedule:
      interval: "daily"

@jurre
Copy link
Member

jurre commented Mar 8, 2022

I don't think this is working.

The change has not been released and rolled out yet, the issue was automatically closed because it was referenced by the commit, I'll reopen it for clarity.

@jurre jurre reopened this Mar 8, 2022
@Pwd9000-ML
Copy link

@jurre Thank you very much for clarification :)

@fmeriaux
Copy link

fmeriaux commented May 5, 2022

For subdirectories it doesn't work (tested today).

But I found a workaround:

version: 2
updates:
  # Maintain dependencies for GitHub Actions (/.github/workflows)
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"

  - package-ecosystem: "github-actions"
    directory: "/actions/<my-custom-action-A>"
    schedule:
      interval: "daily"

  - package-ecosystem: "github-actions"
    directory: "/actions/<my-custom-action-B>"
    schedule:
      interval: "daily"

Dependabot has successfully scanned the files and created PRs.

@georgettica
Copy link

@fmeriaux should you open a card specific with you problem and your workaround?

My guess is that by seeing the problem and your solution it can be solved at the source

@fmeriaux
Copy link

fmeriaux commented May 5, 2022

@fmeriaux should you open a card specific with you problem and your workaround?

My guess is that by seeing the problem and your solution it can be solved at the source

The current issue proposes to support composite actions. When the issue was created this was not the case, since the PR of @JonasAlfredsson they are supported if the action is at the root (of directory configuration).

It is implied that nested composite actions are supported, but this is not the case. So I can open a "bug" in this sense, unless we stay on this issue that is not "solved" entirely.

@JonasAlfredsson
Copy link
Contributor

Hi @fmeriaux ,

I think not traversing into subdirectories is the intended usecase. I do not know if relevant documentation has been updated, but specifying each directory (where an action file is located) is necessary as it is written right now.

While this is perhaps a little bit cumbersome if you have a lot of custom actions, I feel like this is a safer approach than just capturing every action.ya?ml file in either one or unknown levels of subdirectories. However, if the traversing functionality is desired then I do not think it would be too difficult to implement it.

@fmeriaux
Copy link

fmeriaux commented May 5, 2022

Hi @fmeriaux ,

I think not traversing into subdirectories is the intended usecase. I do not know if relevant documentation has been updated, but specifying each directory (where an action file is located) is necessary as it is written right now.

While this is perhaps a little bit cumbersome if you have a lot of custom actions, I feel like this is a safer approach than just capturing every action.ya?ml file in either one or unknown levels of subdirectories. However, if the traversing functionality is desired then I do not think it would be too difficult to implement it.

Yes, I agree with your reasoning. It may be more secure to have an explicit intention in the configuration.

However the documentation is far from clear, I had to experiment and search in your contribution to understand and find a solution to my need.

A good compromise could be to support wildcards, something like:

version: 2
updates:
  # Maintain dependencies for GitHub Actions (/.github/workflows)
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"

  - package-ecosystem: "github-actions"
    directory: "/actions/**"
    schedule:
      interval: "daily"

I can open a new issue for wildcard support, if you want.

@JonasAlfredsson
Copy link
Contributor

Two things:

  1. I am not sure where documentation is located, and how to update it. Is this something @jurre can answer?
  2. I do not have time to look at wildcard matching right now, so please open a ticket and see if someone else in the community has time before me :)

@fmeriaux
Copy link

Done #5137

@brrygrdn brrygrdn added the L: github:actions GitHub Actions label May 24, 2022
TeoZosa added a commit to TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd that referenced this issue Sep 19, 2022
TeoZosa added a commit to TeoZosa/cookiecutter-cruft-poetry-tox-pre-commit-ci-cd that referenced this issue Sep 19, 2022
@jeffwidman
Copy link
Member

Closing as the overall work has been merged / deployed in #4755 and #4815 and then the followup idea of not having to specify subdirectories is tracked in #5137.

Many thanks to @JonasAlfredsson for all his hard work here.

@saisatishkarra
Copy link

saisatishkarra commented Feb 16, 2023

Here's my public repository trying to update dependencies directly in composite actions in sub-folders as supported by #4755 and can't get this to work. Can someone tell me if I am missing something / the feature isn't supported anymore?

Issue: No PR's created against the actions in the subfolder by dependabot.
Expected: https://github.com/ergebnis/.github/blob/main/.github/dependabot.yml and ergebnis/.github#151

@deivid-rodriguez
Copy link
Contributor

This is so interesting because I just tried your case and it's indeed not working. But it seems that #6660 just merged has actually regressed this, so this should've been working for you until today. Could it by that your actions were up to date, and that's why no PRs were created? Anyways, I'll be fixing the regression now.

@saisatishkarra
Copy link

@deivid-rodriguez Yes it seemed to work and create a PR. When I tried to rebase it dependabot closed the PR and is not generate any new ones and was unable to update dependencies in composite actions. The https://github.com/Scimia/public-shared-actions/blob/main/actions/security-actions/scan-docker-image/action.yaml has old versions of anchore/scan-action and anchore/sbom-action which needs to be bumped to v3.3.4 and v0.13.3 respectively. This seems like a regression. I will wait until #6690 and see if that works. Thanks for the PR!!!

@deivid-rodriguez
Copy link
Contributor

@saisatishkarra I just deployed the fix in #6690, can you try whether that works?

@saisatishkarra
Copy link

saisatishkarra commented Feb 21, 2023

@deivid-rodriguez Thanks for the release.
Dependable doesn't seem to be working in 2 use-cases yet:

  1. Update dependencies within a single composite action.
  1. Update the composite action dependency in a different repository workflow.
    -Ex: The uses block in a workflow (repoA) referring to a composite action in a repoB must be updated when referenced using SHA, tag.

@deivid-rodriguez
Copy link
Contributor

Regarding the first issue, I think it should be working. Can you try manually checking for updates at the "Insights > Dependency Graph > Dependabot" tab?

Regarding the second problem, can you open a separate issue with steps to reproduce?

Thanks!

@saisatishkarra
Copy link

Manually triggering the checking for updates from the insights tab seemed to have worked and updated the PRs. I guess we can mark it resolved and dependable to automatically pick up any new updates later down the line.

Screen Shot 2023-02-21 at 9 47 45 AM

I have filed a bug previously for the second problem but this was supposed to be addressed from #6690 and #6660. I don't think this is still working. Appreciate someone taking a look and if I am missing something.

Thanks again for the prompt response.

@deivid-rodriguez
Copy link
Contributor

Oh, sorry I missed that other issue you had opened. I will check that again and let you know exactly what to expect there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: github:actions GitHub Actions T: feature-request Requests for new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.