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

Update container image references in GitHub Action workflows #5819

Open
1 task done
lorengordon opened this issue Sep 30, 2022 · 11 comments
Open
1 task done

Update container image references in GitHub Action workflows #5819

lorengordon opened this issue Sep 30, 2022 · 11 comments
Labels
T: feature-request Requests for new features T: new-ecosystem Requests for new ecosystems/languages

Comments

@lorengordon
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Feature description

I've used Dependabot to update the FROM argument in a Dockerfile, but now I'm starting to use images directly in GitHub Actions, which does not use a Dockerfile. I would still like Dependabot to update the image reference in the workflow file though. Is there a way to do this today? (I did search the docs and issues but couldn't find anything.)

See: https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container

Syntax in the workflow files looks like this:

name: CI
on:
  push:
    branches: [ main ]
jobs:
  container-test-job:
    runs-on: ubuntu-latest
    container:
      image: node:14.16
@lorengordon lorengordon added the T: feature-request Requests for new features label Sep 30, 2022
@jeffwidman
Copy link
Member

This may be what #2307 is trying to get at, although that code seems slightly different since it's looking for the docker keyword, not the container keyword... so I may be misunderstanding.

For now, adding new ecosystems / new places to search for updates is on pause... we hope to have a better story there in the not too distant future, but we're just not ready to provide the level of support required for a new ecosystem.

@jeffwidman jeffwidman added the T: new-ecosystem Requests for new ecosystems/languages label Oct 1, 2022
@lorengordon
Copy link
Contributor Author

That's an alternate syntax, applies to the uses argument... That would work also, though container is nice because you can control more of the docker options.

@lorengordon
Copy link
Contributor Author

Looks like I could use Renovate instead, they recently released support for this, renovatebot/renovate#16770

@jeffwidman
Copy link
Member

jeffwidman commented Oct 3, 2022

Thanks for clarifying and including the docs links.

Glad Renovate can help you get unblocked... hopefully in the not-too-distant future we can support this here as well.

@ssbarnea
Copy link

ssbarnea commented Oct 5, 2022

I have the same need, https://github.com/ansible-community/ansible-lint-action/blob/main/action.yml#L26 does not update by itself.

@jeffwidman jeffwidman changed the title Update container image references in GitHub Action workflows Update Docker container image references in GitHub Action workflows Nov 23, 2022
@jeffwidman jeffwidman changed the title Update Docker container image references in GitHub Action workflows Update Docker / container image references in GitHub Action workflows Nov 23, 2022
@jeffwidman jeffwidman changed the title Update Docker / container image references in GitHub Action workflows Update container image references in GitHub Action workflows Feb 5, 2023
@pascalknupper
Copy link

Is there any update on this feature-request?

@thepwagner
Copy link
Contributor

thepwagner commented Mar 7, 2024

👋 For similar YAML formats, a weird workaround for this is to add:

apiVersion: lol
kind: trollololol

That will trick Dependabot into thinking the file is a Kubernetes resource - so it will find and manage any image: keys in the YAML - https://github.blog/changelog/2022-11-16-dependabot-version-updates-for-docker-image-tags-in-kubernetes-manifests/

Per @franzliedke 👇 - this hack won't work for Actions because it violates Actions' schema.

An idea for this feature, you could align the conditions in the FileFetcher with those in the FileParser. My ideal would be any image: ${stringThatMatchesTheImageSpec} in the directory that I told Dependabot about will be managed.
That patch would support GitHub actions, as well as other YAML formats that just happen to use image: as the key - https://github.com/search?q=path%3A.yml+%2Fimage%3A.*%40sha256.*%2F&type=code (docker-compose.yaml seems the common - #390)

@franzliedke
Copy link

@thepwagner Can you explain how to apply that hack without triggering the GitHub workflow validation? 🤔

@thepwagner
Copy link
Contributor

@franzliedke sorry I hadn't tested it specifically for Actions.
My use case is a custom and private YAML format. Nothing is strict about the schema, so the hack works for me. Its effectiveness for Actions was a (bad) assumption.

I left the comment here because:

  • it had the most discussion about extracting image: tags from non-Kubernetes YAML files
  • my proposed fix of promoting the FileParser style so that ANY image: keys in any YAML schema would work for my use case and Actions at the same time.

I'll update to remove the lie - thanks for testing it! 🧪 .

@thomasleplus
Copy link

thomasleplus commented Jun 2, 2024

That's an alternate syntax, applies to the uses argument... That would work also, though container is nice because you can control more of the docker options.

* https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-docker-hub-action

* https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainer

FYI the docker:// workaround is not working for me. First I though that the obscure docker container I am using might not part of dependabot docker images index so I switched to an old version of a more mainstream image (amazon/aws-cli:2.15.60). After 48h I am still waiting for a dependabot PR and nothing. I use the same aws-cli image as the parent (FROM) in another repo's Dockerfile and I got a PR from dependabot there already so I know for sure dependabot is aware of the new version and has pushed PRs for it via the docker ecosystem.

Another limitation of uses: is that it doesn't support the run: command so you can't execute anything other than the default entry point of the container, unlike image:.

So I hope dependabot will consider supporting the container as the OP suggested without needing any hack or workaround. Thanks either way for making a great product.

@allanlewis
Copy link

allanlewis commented Jun 2, 2024

Another limitation of uses: is that it doesn't support the run: command so you can't execute anything other than the default entry point of the container, unlike image:.

You can set with.args to set the command, as per docker run <image> <args> - if you want to use a different entry point then it's usually better to write a Dockerfile based on the image you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: feature-request Requests for new features T: new-ecosystem Requests for new ecosystems/languages
Projects
None yet
Development

No branches or pull requests

8 participants