Use output from GitHub Actions container image build to feed tag value - github

Synopsis
My overarching objective is to automate the build and publish of a container image to the GitHub Packages registry (and/or DockerHub). I have already set up a project that accomplishes this, however there's a "gotcha."
I want to use output from the container image build process to update the tag that's assigned to the container image.
For example:
ghcr.io/pcgeek86/aws-powershell:<versionNumber>
The Caveat
Unfortunately, the GitHub Action for Docker does a build and a push simultaneously. Hence, I am unable to capture the output from the container image build, parse the version number, and then update the environment variable containing the new tag value.
Question
Is there a way to separate the container 1) build and 2) push into separate steps, so that I can capture the build output and use that to modify the container image tag, before it's pushed up to the GitHub Packages registry?

Related

In azure container apps, does each revision save its own copy of a docker image?

Since my project is still just in development, when making my builds, I always push and replace a single docker image in ACR with the :latest tag. My app is in 'Multiple' revision mode and my build script creates a new revision based on the latest as a template.
Now, I had a persistent provisioning failure, so I attempted to activate my latest successfully provisioned revision, but it still failed with the same error.
Does each revision need to be created with it's own separate source image, in order for me to be able to return to a previous build if my current one fails? What is the safest approach for production?
Does each revision need to be created with it's own separate source image, in order for me to be able to return to a previous build if my current one fails? What is the safest approach for production?
Yes, the image isn't copied. It'll be pulled from your registry every time the revision is activated or scales out or moves between VMs.
You can use a git commit id or a build version for the image tag.

List available docker tags when creating a release

Backstory:
We have a web app that creates batch jobs in Azure using docker images. In the application configuration there is a parameter to defines which version of the docker image the batch job should use. In our current setup we need to manually change the parameter if we deploy a new version of the docker image.
What I want to do is choose which docker image to use when I create a release for the web app. I already have a working release pipeline where I manually type in which version of the docker image I want to use, but I would like to be able to choose from the available docker images in the repository. The docker images are built in Azure devops and we have a tag on each build with the version number.
Is it possible to achieve this?

How does CodePipeline's ECR source action detect a change to an image in ECR?

I am setting up a pipeline with an Amazon ECR source to ECS deploy. Have been following the steps in the tutorial here.
My issue is when my private ECR is updated with a docker image the pipeline is not triggered. I am not applying the latest tag on the image, just using a semantic versioning tag which includes a build number and a short Git commit hash, for eg:
myserver:b21-6d22b379a
myserver:b20-c90b134a
etc..
In the Image Tag option in the ECR source action it says: Choose the image tag that triggers your pipeline when a change occurs in the image repository.
If I leave it blank and just specify the ECR repository name such as myserver, will it look for a new image only if the latest tag is moved to another image with a different SHS digest in ECR?
Or is it smart enough to detect the change in ECR based on the timestamp + SHA digest of a new image even if the image did not have the latest tag applied?
I want to avoid using the latest image tag, as with an ECS Fargate cluster my understanding is a new container will simply pull the latest tag irrespective of if CodeDeploy has published a new task def with a new image tag.
So how does one specify the Image & Tag in the ECR source action if not using the latest tag on the docker image in ECR? Does it require a fixed tag to be used for the auto deploy from ECR to ECS to work?
As per https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-ECR.html#action-reference-ECR-config :
If a value for ImageTag is not specified, the value defaults to latest
So if you leave "ImageTag" empty, only images with the "latest" tag will get deployed.
And yes it requires a fixed tag for deployment to work. As such the use of tags is limited - you can, for example, use tags to ensure a specific image only gets deployed in a specific environment (e.g. images tagged "staging" get deployed in staging environment, and images tagged "production" get deployed in production environment) - but you can't use tags dynamically.

GitHub Repositories (How to Run)

I have read the following answer here about how to run a specific file.
However, let's say I want to run every single aspect of code in the entire repository here that uses MathJax without downloading it.
How would one figure that out and do that? Is it one JavaScript source code that you script?
If so, how do you figure out the URL that you run?
IF you really don't want to download a repository, you might consider using a GitHub Action.
It does access your code on GitHub side, and can execute whatever you need.
A GitHub Action has an API, and use GitHub runner (on GitHub side, so no download on your part) as opposed to self-hosted runner.
A workflow can be anything you need, like for instance github-action-build, to build your project, in a repository-specific fashion.
As an example, github-action-for-latex compile Latex documents, using a Docker image (xu-cheng/latex-docker).
You would need a similar approach, using a Docker image where you can clone that repository, and execute it (because the Docker image would have everything needed to run your project).
And that would be done entirely on GitHub (Azure-based) side.

Updating ECS task definition image using Codeship

I'm trying to determine the best way to generate a new or update an existing AWS ECS task definition JSON file using Codeship's codeship/aws-deployment image.
I don't want to rely on the implicit :latest tag within my task definition and wish to use the custom image tag generated in a previous step which pushes to AWS ECR.
Is a custom bash or python script to pull the current task definition, increment the version and replace the image string the only way to accomplish this or is there an existing CLI tool I'm glossing over?