简体   繁体   English

如何使用私有 docker 镜像作为自定义 Github 操作?

[英]How do you use a private docker image as a custom Github action?

hope you can help me out.希望你能帮帮我。 This is killing me.这要死我了。

I have two repos: RepoA and RepoB within one org.我有两个仓库:一个组织内的 RepoA 和 RepoB。 RepoA contains all infrastructure related stuff and some deployment tools. RepoA 包含所有基础设施相关的东西和一些部署工具。 I want to use them in RepoB.我想在 RepoB 中使用它们。 I created a GH docker action in RepoA and i want to simply use it in RepoB.我在 RepoA 中创建了一个 GH docker 操作,我想在 RepoB 中简单地使用它。 I tried this:我试过这个:

      - name: Get AWS account ID
        id: aws-account-id
        uses: my-org/RepoA/gh-actions/get-aws-account-id/@v1

But it doesn't work, it gives: An action could not be found at the URI 'https://api.github.com/repos/my-org/RepoA/tarball/8b657ce314c4af6e3c0d444671c642d54aaea412'但它不起作用,它给出:在 URI 'https://api.github.com/repos/my-org/RepoA/tarball/8b657ce314c4af6e3c0d444671c642d54aaea412'上找不到操作

So I figured, I build a docker image and push to GH packages within my org, but when I use this:所以我想,我构建了一个 docker 镜像并推送到我的组织内的 GH 包,但是当我使用它时:

      - name: Get AWS account ID
        id: aws-account-id
        uses: docker://docker.pkg.github.com/my-org/RepoA/get-aws-account-id:latest

It complains about missing credentials.它抱怨缺少凭据。

Is there any way I can use a custom GH action that is NOT placed in the current repo?有什么方法可以使用未放置在当前存储库中的自定义 GH 操作?

If you want to use a GitHub action that is not placed in your Repo then you can publish it to marketplace and just use it from there.如果您想使用未放置在您的 Repo 中的 GitHub 操作,那么您可以将其发布到市场并从那里使用它。

Otherwise,除此以外,

  • Second option is to copy all the contents of the GitHub action you created (entrypoint.sh, dockerfile and action.yml) to the repository where you want to use it and simply use it like this: uses: ./第二种选择是将您创建的 GitHub 操作的所有内容(entrypoint.sh、dockerfile 和 action.yml)复制到您要使用它的存储库中,然后像这样简单地使用它: uses: ./

Do let me know if this solves your problem, thanks如果这能解决您的问题,请告诉我,谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM