Skip to content

Commit 906a77a

Browse files
committed
ref: docker build
1 parent 0dc9d40 commit 906a77a

File tree

3 files changed

+33
-94
lines changed

3 files changed

+33
-94
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
name: Release Build
1+
name: Docker Build and Release
22

33
on:
44
push:
5+
branches:
6+
- master
57
tags:
6-
- "v*.*.*"
8+
- "v*.*.*"
9+
pull_request:
10+
branches:
11+
- master
712

813
jobs:
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."

.github/workflows/dbuild.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/tbuild.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)