Skip to content

Instantly share code, notes, and snippets.

@caracolmzd
Created June 28, 2024 17:05
Show Gist options
  • Select an option

  • Save caracolmzd/121bfb3b3ac56aa0283e4946da52bcd8 to your computer and use it in GitHub Desktop.

Select an option

Save caracolmzd/121bfb3b3ac56aa0283e4946da52bcd8 to your computer and use it in GitHub Desktop.
DockerHub Publish Branch on new Tag
name: Publish Docker Image
on:
push:
tags:
- v*
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Rebase publish on main
run: |
git checkout publish
git pull origin main
git merge --no-commit --no-ff main
if [ -z "$(git diff --cached --name-only)" ]; then
git commit -m "Rebase publish on main"
git push origin publish
else
echo "Conflicts detected, aborting rebase."
exit 1
fi
- name: Build and push Docker image
run: |
# Your Docker image building and pushing script goes here
# For example:
docker build -t my-image .
docker tag my-image $GITHUB_SHA
docker push my-image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment