Skip to content

Commit 1719273

Browse files
authored
github actions
1 parent d08bd8c commit 1719273

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

.github/workflows/docker-publish.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,39 @@ name: Build and Push Docker Image
33
on:
44
push:
55
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
68
release:
79
types: [ published ]
810

911
jobs:
10-
build-and-push:
12+
13+
build-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Build Docker image
21+
run: |
22+
docker build -f ./docker/Dockerfile -t tradenode:test .
23+
24+
- name: Test Docker image
25+
run: |
26+
docker run --rm tradenode:test > /tmp/test.log
27+
28+
if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then
29+
echo "Build successful"
30+
else
31+
echo "Build failed!"
32+
exit 1
33+
fi
34+
35+
push-to-ghcr:
1136
runs-on: ubuntu-latest
37+
if: github.ref == 'refs/heads/main'
38+
needs: build-test
1239
permissions:
1340
contents: read
1441
packages: write
@@ -30,10 +57,12 @@ jobs:
3057
with:
3158
images: ghcr.io/${{ github.repository }}
3259

33-
- name: Build and push Docker image
34-
uses: docker/build-push-action@v5
60+
- name: Build and push
61+
uses: docker/build-push-action@v6
3562
with:
3663
context: .
64+
platforms: linux/amd64,linux/arm64
65+
file: ./docker/Dockerfile
3766
push: true
3867
tags: |
3968
ghcr.io/${{ github.repository }}:latest

0 commit comments

Comments
 (0)