Skip to content
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

workflows(atlantis-image): fix building and publishing of Docker images #1975

Merged
merged 1 commit into from
Jan 5, 2022
Merged

workflows(atlantis-image): fix building and publishing of Docker images #1975

merged 1 commit into from
Jan 5, 2022

Conversation

Tenzer
Copy link
Contributor

@Tenzer Tenzer commented Jan 5, 2022

#1943 changed the way Docker images
were built in GitHub Actions so multi-architecture Docker images now are built,
but it unfortunately included a bug which means it hasn't worked yet on any
released version of Atlantis.

The problem is the change expected environment variables to be replaced in the
regular YAML code instead of just the commands which are run.

This attempts to fix that by instead using the template language available to
access the same environment variable.
This is based on the example provided in the documentation here:
https://docs.github.com/en/actions/learn-github-actions/environment-variables.

#1943 changed the way Docker images
were built in GitHub Actions so multi-architecture Docker images now are built,
but it unfortunately included a bug which means it hasn't worked yet on any
released version of Atlantis.

The problem is the change expected environment variables to be replaced in the
regular YAML code instead of just the commands which are run.

This attempts to fix that by instead using the template language available to
access the same environment variable.
This is based on the example provided in the documentation here:
https://docs.github.com/en/actions/learn-github-actions/environment-variables.
@Tenzer Tenzer requested a review from a team as a code owner January 5, 2022 09:13
@@ -49,13 +49,13 @@ jobs:
- name: populate release version
if: ${{ github.event_name == 'release'}}
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and push atlantis:$RELEASE_VERSION image
- name: Build and push atlantis:${{ env.RELEASE_VERSION }} image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I think this used to working fine at some point before.

But now when I looked back at 0.17.3 release build (https://github.com/runatlantis/atlantis/runs/3478283112), the RELEASE_VERSION shows unset in the log.

I dont think this is quite a right fix. You can see my test build in here, https://github.com/chenrui333/github-action-test/runs/4715966380

The image does get successfully tagged.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow you. The first release that happened since the changes from #1943 got merged was the version 0.17.6 release. You can see the job from that run here: https://github.com/runatlantis/atlantis/runs/4564698591?check_suite_focus=true.

The workflow you are linking to is running the docker build command directly, which means environment variables are expanded. This was changed in .github/workflows/atlantis-image.yml in #1943 to instead use the docker/build-push-action action, which doesn't expand environment variables, which is why the environment variable instead has to be accessed as via the template language.

Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, that makes total sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@virgofx Did you use this image ghcr.io/runatlantis/atlantis:latest@sha256:66d431df3cd1893175abf7133aeef96f9ab212a3c260daf8ef2a54042259f503? Mind creating a bug ticket?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost positive that's what I used. Let me re-test real quick and confirm.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep confirmed using
ghcr.io/runatlantis/atlantis:latest@sha256:66d431df3cd1893175abf7133aeef96f9ab212a3c260daf8ef2a54042259f503
results in:
standard_init_linux.go:228: exec user process caused: exec format error

I'll create a new issue.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed. Spun out a new issue: #2001

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @virgofx!

@chenrui333 chenrui333 changed the title Fix building and publishing of Docker images workflows(atlantis-image): fix building and publishing of Docker images Jan 5, 2022
@chenrui333 chenrui333 merged commit 1a342ed into runatlantis:master Jan 5, 2022
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
…es (runatlantis#1975)

runatlantis#1943 changed the way Docker images
were built in GitHub Actions so multi-architecture Docker images now are built,
but it unfortunately included a bug which means it hasn't worked yet on any
released version of Atlantis.

The problem is the change expected environment variables to be replaced in the
regular YAML code instead of just the commands which are run.

This attempts to fix that by instead using the template language available to
access the same environment variable.
This is based on the example provided in the documentation here:
https://docs.github.com/en/actions/learn-github-actions/environment-variables.
@chenrui333 chenrui333 added the docker Pull requests that update Docker code label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Pull requests that update Docker code docker-multi-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants