-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add workflow that builds Docker and push to ECR without using artifacts #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
I would make push an input and make it default true.
docker_push:
description: "Push Image to ECR"
type: boolean
required: false
default: true
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} | ||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a condition here to be master or main or feature branches will push to latest.
Also add the git sha, should
always be a tag on an image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swibrow I agree with this. I was running into errors though if I was specifying twice the SHA (because IMAGE_TAG
was also assuming the git.sha
value). That's why I removed it. Should I make a condition? but then not sure how to parametrize the tags
parameter dynamically of the custom action...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags: |
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ github.sha }}
${{ env.IMAGE_TAG != github.sha && format('{0}/{1}:{2}', env.REGISTRY, env.REPOSITORY, env.IMAGE_TAG) }}
something like that (not tested) or just use standard docker commands since running the same tag command wont error.
Also if you want to use the docker action, theres also a tag extractor
https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
@@ -173,6 +172,11 @@ jobs: | |||
run: | | |||
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY | |||
|
|||
# Added this step because otherwise the UI shows a green checkmark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be added to the step above?
I would remove the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We want to create anyway the summary, so we can't exit before that.
- We don't want to exit at the summary step or this would be misleading because it would look like the summary step failed while it was the plan one that failed.
What do you think? I think like this is the cleanest I could think of.
…urt) and merge multiple ones
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} | ||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tags: |
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ github.sha }}
${{ env.IMAGE_TAG != github.sha && format('{0}/{1}:{2}', env.REGISTRY, env.REPOSITORY, env.IMAGE_TAG) }}
something like that (not tested) or just use standard docker commands since running the same tag command wont error.
Also if you want to use the docker action, theres also a tag extractor
https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
@@ -173,8 +181,12 @@ jobs: | |||
run: | | |||
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY | |||
|
|||
- name: Exit if `terraform plan` failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore. since it wont make it this far
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this should be removed I guess
- name: Terraform Apply | ||
if: (github.ref_name == github.event.repository.default_branch && github.event_name == 'push' && steps.plan.outputs.exitcode == '2') || inputs.tf_deploy_override == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want this actually since you only want to run an apply when theres changes.
It's faster