Add GitHub actions workflow to automaticall build and push Docker images #179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a workflow to automatically build and push docker images to Dockerhub on build and release. The workflow is based on the Dockerfile from #163 and only works on that base.
The Mosquitto versions can be adjusted with the
MOSQUITTO_VERSION_1
andMOSQUITTO_VERSION_2
environment variables. These need to be adjusted manually since I didn't find a way to automatically track the latest 1.x and 2.x release.The
sed
command replaces the Mosquitto version part in the Dockerfile with the version from the env variables, if the line in the Dockerfile get's changed, theDOCKERFILE_MOSQUITTO_VERSION
variable needs to be adjusted too.The image naming can be adjusted with the
MOSQUITTO_VERSION_SUFFIX
andMOSQUITTO_VERSION_1
andMOSQUITTO_VERSION_2
environment variables. These are added after the version tag on release (1.5.0-mosquitto_1.6.14
) or tolatest
on push (latest-mosquitto_1.6.14
).latest
is equivalent to the latest build with Mosquitto version 2.x.The
DOCKERHUB_REPO
environment variable defines to which repo on Dockerhub the Docker images get pushed.To use this workflow, you need to add your Dockerhub username (
DOCKERHUB_USERNAME
) and a Dockerhub access token (DOCKERHUB_TOKEN
) to your Github repository secrets. Please be aware that the name of the secrets must be identical to the variable names used in the workflow.Here are two ressources how to add the needed secrets to your repository:
All used actions besides the
sed
command are from either Github or Docker themselves.If you got any questions or concerns, I'll do my best to answer them. One word of caution which you probably already know: Don't activate Github action workflows for pull requests without prior approval from you.
This isn't really related to this pr, but since I kinda introduced Github actions into this repo, I feel obligated to mention it.