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

Upgrading Build Workflow to publish Docker Images on each Release #527

Merged

Conversation

rseedorff
Copy link
Contributor

@rseedorff rseedorff commented Sep 27, 2021

This PR if applied closes #521 by upgrading the sslyze repository GitHub Actions and Workflows.

  • Updated the Docker Image to the newest Python image 3.9-slim and switched the installation process to a source based instead of pip to prevent race conditions in the release process

  • Added a new release pipeline which will be triggered with every new GitHub release to publish the corresponding Docker Image to DockerHub. To get this work you have to add 3 new repository secrets with the namespace and a docker user with red & write permission for the docker repository:

    • DOCKER_NAMESPACE: nablac0d3
    • DOCKER_USERNAME: nablac0d3
    • DOCKER_TOKEN: YOUR_USER_PASSWORD

    I tested the release pipeline already within our fork successfully (with our project docker repo instead): https://github.com/secureCodeBox/sslyze/runs/3722635578?check_suite_focus=true

@nabla-c0d3
Copy link
Owner

Hey this is great! One request tho - can you revert to separate workflows (scan_nginx_server.yml, etc.). They were separate by design. Once you've done that I will take a look again but overall it looks good! Thanks,

Copy link
Owner

@nabla-c0d3 nabla-c0d3 left a comment

Choose a reason for hiding this comment

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

I asked for a couple more small changes and then this should be good to go. Thanks!

.github/workflows/release-build.yaml Outdated Show resolved Hide resolved
.github/workflows/scan_apache2_server.yml Outdated Show resolved Hide resolved
in all scan workflows
due to PR Review Feedback
race conditions during release process with pip
@rseedorff rseedorff changed the title Upgrading Build Workflow to publish Docker Images on Release Upgrading Build Workflow to publish Docker Images on each Release Oct 1, 2021
@rseedorff rseedorff marked this pull request as ready for review October 1, 2021 08:23
@rseedorff
Copy link
Contributor Author

@nabla-c0d3 ready when you are 🙂

@nabla-c0d3 nabla-c0d3 merged commit 7e16dc0 into nabla-c0d3:release Oct 2, 2021
@nabla-c0d3
Copy link
Owner

Thank you!

@nabla-c0d3
Copy link
Owner

@rseedorff I tried to trigger the workflow just now by creating the "test-docker-release-1" git tag, but nothing happened. The workflow was not triggered. What am I doing wrong? Thanks!

@rseedorff
Copy link
Contributor Author

@nabla-c0d3 First of all it is necessary to define the repo secrets mentioned in my PR description.
Secondly the workflow will be started only by creating a new GitHub release here: https://github.com/nabla-c0d3/sslyze/releases Just tagging is not enough 😕

Hint 1:
If you want to test the workflow before publishing a new sslyze release you can temporary add a on push for example into the workflow :

on:
  push:
  release:
    types: [released]

Hint 2:
If it is important to you to trigger this workflow only by pushing a tag it must be defined like the following example (not tested yet):

# Only release on a new tag that is a version number.
on:
  push:
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'

I found this solution here:

@nabla-c0d3
Copy link
Owner

nabla-c0d3 commented Oct 6, 2021

@rseedorff Thanks!

I just tried and it looks like it worked 😀: https://hub.docker.com/r/nablac0d3/sslyze/tags?page=1&ordering=last_updated (from https://github.com/nabla-c0d3/sslyze/releases/tag/test-docker-release-1).

One thing tho: the tag in Dockerhub should have the same name as the tag (or release name) in GitHub. Hence in Dockerhub, the above tag should have been called test-docker-release-1, but instead it is called "sha-7e16dc0".

Any ideas on how to send the proper tag name to Dockerhub? It can also be the release name (in SSLyze tag name and release name are the same).

@rseedorff
Copy link
Contributor Author

Hi @nabla-c0d3,

great news 🎉
The sha tag is introduced due to the following definition in the workflow Action (https://github.com/docker/metadata-action#typesha). You can drop this tag option, its optional:

        with:
          images: ${{ env.DOCKER_NAMESPACE }}/sslyze
          tags: |
            type=sha 

The second tag definition is based on the semver string format (https://github.com/docker/metadata-action#typesemver) and uses your release tag for that ({{version}}):

with:
          images: ${{ env.DOCKER_NAMESPACE }}/sslyze
          tags: |
            type=sha
            type=semver,pattern={{version}}

Since your tag name test-docker-release-1) is not compliant to the sermver format i would guess its dropped. It should work with an valid release tag like v4.2.0-rc.1

@nabla-c0d3
Copy link
Owner

Hi @rseedorff ,

Thank you and sounds good. I will then try it with the next release, which will be properly formatted (it will be 5.0.0). It looks like we are good to go 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker Tag v4.1.0 is missing 🤔
2 participants