1- name : Release Build
1+ name : Docker Build and Release
22
33on :
44 push :
5+ branches :
6+ - master
57 tags :
6- - " v*.*.*"
8+ - " v*.*.*"
9+ pull_request :
10+ branches :
11+ - master
712
813jobs :
914 build-docker-image :
@@ -27,12 +32,34 @@ jobs:
2732 username : ${{ secrets.DOCKERHUB_USERNAME }}
2833 password : ${{ secrets.DOCKERHUB_TOKEN }}
2934
35+ - name : Determine Docker Tags
36+ id : tags
37+ run : |
38+ if [[ $GITHUB_REF == refs/tags/* ]]; then
39+ echo "RELEASE_BUILD=true" >> $GITHUB_OUTPUT
40+ echo "TAGS=erfjab/holderbot:latest,erfjab/holderbot:${{ github.sha }}" >> $GITHUB_OUTPUT
41+ elif [[ $GITHUB_REF == refs/heads/master && github.event_name == 'push' ]]; then
42+ echo "TAGS=erfjab/holderbot:ga,erfjab/holderbot:${{ github.sha }}" >> $GITHUB_OUTPUT
43+ elif [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
44+ echo "TAGS=erfjab/holderbot:pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
45+ fi
46+
3047 - name : Build and Push Docker Image
3148 uses : docker/build-push-action@v3
3249 with :
3350 context : .
3451 platforms : linux/amd64,linux/arm64
35- push : true
36- tags : |
37- erfjab/holderbot:latest
38- erfjab/holderbot:${{ github.sha }}
52+ push : ${{ github.event_name != 'pull_request' || github.ref == 'refs/heads/master' }}
53+ tags : ${{ steps.tags.outputs.TAGS }}
54+
55+ - name : Print Success Message
56+ if : success() && github.event_name == 'pull_request'
57+ run : |
58+ echo "✅ Docker Image built successfully!"
59+ echo "You can test it using the following command:"
60+ echo "docker run -it --rm erfjab/holderbot:pr-${{ github.event.pull_request.number }}"
61+
62+ - name : Print Failure Message
63+ if : failure()
64+ run : |
65+ echo "❌ Docker Image build failed! Please check the logs for more details."
0 commit comments