-
I can’t figure how how to get the second script right, after I create the image: I’m trying to move away from using a script I had been using to build and push docker images where I was using docker/build-push-action. I don’t care about retaining the old images from GitHub Packages Docker registry. I just want to push a new image to the Google Container Registry at this point. I am now running a script to create the image myself and push it to the new Google Container Registry route. So here are my new jobs:
Now I’m not really sure what the image name is that it actually creates. I see that it generated a sha or hash or something and my tag. Apparently
I get:
Other Info (in case it helps) I took a look at Migrating to GitHub Container Registry for Docker images but not sure if I’m missing something related to that or it’s just a dumb mistake I made above somewhere that I’m just not seeing. I want to think it’s maybe the latter…? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Before you push an image to a Docker or container registry, you need to build (if need) and tag the image.
OR
The REPOSITORY should contain the registry’s domain and name of the target repository or owner on the registry, so that the ‘docker push’ command can know where the image is pushed to. If the REPOSITORY does not contain registry’s information when you tag the image, and only set the registry’s information when pushing the image, the ‘docker push’ command will not recognize registry’s information and it will return the error message like as you have seen:
This also has been mentioned in “Migrating to GitHub Container Registry for Docker images”. |
Beta Was this translation helpful? Give feedback.
-
Yes I’m already building it, above I have:
I’ve since then gone a little further. Pretty sure I need to be using the Image ID not we-do-tdd in my push job. So I’m working on trying to persist that newly created image ID as an environment variable that my push job can use:
Notice this updated script sets it as an environment variable called
Problem here now is I have verified that this does indeed set the environment variable: but just my last job when it tries to access it, that value is lost. And again I’m not MOVING an EXISTING image, I’m creating a NEW image and on the fly, trying to push that up to the new GitHub Container Repository. |
Beta Was this translation helpful? Give feedback.
-
In a job, the environment variable you set via the ‘set-env’ command in a step will be only available to the subsequent steps in the same job. The steps in other jobs can’t access this environment variable. More details, see “Setting an environment variable”. If you want to access this value in the subsequent job, you can set it as an output of the previous job.
|
Beta Was this translation helpful? Give feedback.
-
Thanks very much! I’ll try this, I was spending hours on trying to figure out this combination! I’m off to bed so will try it when I wake for the day |
Beta Was this translation helpful? Give feedback.
-
you’re welcome, @dschinkel . In addition, the following is an example mentioned in the docs about workflow syntax, you also can reference to it: |
Beta Was this translation helpful? Give feedback.
-
So I was able to get the environment variable working, thanks for the tip. I hadn’t seen that part of the documentation for some reason. |
Beta Was this translation helpful? Give feedback.
@dschinkel ,
In a job, the environment variable you set via the ‘set-env’ command in a step will be only available to the subsequent steps in the same job. The steps in other jobs can’t access this environment variable. More details, see “Setting an environment variable”.
If you want to access this value in the subsequent job, you can set it as an output of the previous job.
In your case, you can do like as this: