I would like to achieve the following CI pipeline with GitHub Actions workflow.
Pull Request is merged -> GitHub action is being triggered -> docker image is being built with semantic version incremented by one or the version is based on GitHub tag – if it is possible to somehow tag the pull request merge.
How to achieve that or is the better approach?
I have tried with secrets but no to avail. How to implement semantic versioning in GitHub Actions workflow?
3
Answers
${{github.ref_name}}
pulls the tag for you or run git command likegit describe --abbrev=0
in the previous step to get the latest tag and append it to image name and use it like:You can use a lot of semver actions on the market place.
For example, I have tried using this – Semver action
This will bump your repo version, and you can use a git bash command to get that bumped version on the next job.
So combining with docker build, you can do something like:
Here’s my public solution: a more or less trivial docker image, built and run during pull requests, bumping version based on commits when pushed to main. All based on the awesome work of others out there, i.e. using existing GitHub actions.
details: https://github.com/DrPsychick/docker-githubtraffic/tree/main/.github/workflows