简体   繁体   中英

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 contains all infrastructure related stuff and some deployment tools. I want to use them in RepoB. I created a GH docker action in RepoA and i want to simply use it in 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'

So I figured, I build a docker image and push to GH packages within my org, but when I use this:

      - 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?

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.

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: ./

Do let me know if this solves your problem, thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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