DEV Community

Discussion on: Publish your own Docker Images with GitHub Actions

Collapse
 
snakepy profile image
Fabio

Hey thank you for your feedback!

I knew I can do better than what I have! I very recently got into githubworkflows, I am not used to using premade jobs. In my company we use gitlab for our workflow and there you usually code it yourself. But I definitly gonna check the repositories out!

I already had a look into your workflow file. I must admit I find my solution more readable. I miss YAML Anchors so I can make it even more readable.

But I want to improve it and condense it to one file and yes currently I am just deplying to one registry, but this might change!

Collapse
 
cicirello profile image
Vincent A. Cicirello

If you are hoping to condense the 2 workflows into one, you can probably use a conditional step that checks which event triggered that run. For example:

      - if: ${{ github.event_name == 'push' }}
        run: # thing you want to do on a push
Enter fullscreen mode Exit fullscreen mode

And then something similar for the schedule event.

Thread Thread
 
snakepy profile image
Fabio • Edited

I thought of doing it in a similar way! :D But it didn't work yet. I will revisit this next week.

Collapse
 
cicirello profile image
Vincent A. Cicirello

Your workflow is very readable. The step I named prepare is almost certainly more complicated than it needs to be. It is getting the release tag from the github release that triggered the workflow, and generating a list of tags for the image. From a github release tag of let's say v3.2.1, I'm dropping the v and tagging the docker image with: latest, 3.2.1, 3.2, and 3 (the step that does all of that looks very messy).