Created
June 28, 2024 17:05
-
-
Save caracolmzd/121bfb3b3ac56aa0283e4946da52bcd8 to your computer and use it in GitHub Desktop.
DockerHub Publish Branch on new Tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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