6161 goreleaser release --clean --rm-dist
6262 env :
6363 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+
65+ - name : Run GoReleaser Docker Push
66+ if : |
67+ (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
68+ (github.event_name == 'pull_request' &&
69+ github.event.action == 'closed' &&
70+ github.event.pull_request.merged == true &&
71+ github.event.pull_request.base.ref == 'main')
72+ run : |
73+ export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
74+ goreleaser release --rm-dist --skip-publish --snapshot
75+ env :
76+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
77+
78+ - name : Set up QEMU
79+ uses : docker/setup-qemu-action@v3
80+
81+ - name : Set up Docker Buildx
82+ uses : docker/setup-buildx-action@v3
83+
84+ - name : Download BPF object file
85+ run : |
86+ gh release download --repo SentinalFS/file-monitor --clobber --pattern "monitor.bpf.o"
87+
88+ - name : Decide to push or not
89+ id : decide
90+ run : |
91+ if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
92+ echo "PUSH=true" >> $GITHUB_ENV
93+ else
94+ echo "PUSH=false" >> $GITHUB_ENV
95+ fi
96+
97+ - name : Build Image
98+ if : env.PUSH == 'false'
99+ run : |
100+ docker buildx build \
101+ --platform linux/amd64,linux/arm64 \
102+ --build-arg TARGETARCH=amd64 \
103+ --file Dockerfile \
104+ -t siddh34/go-ebpf-logger:latest \
105+ -f Dockerfile64.amd64 .
106+
107+ - name : Login to DockerHub
108+ if : env.PUSH == 'true'
109+ run : echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login -u "siddh34" --password-stdin
110+
111+ - name : Build & Push Docker images
112+ if : env.PUSH == 'true'
113+ run : |
114+ docker buildx build \
115+ --platform linux/amd64,linux/arm64 \
116+ --file Dockerfile \
117+ --push \
118+ -t siddh34/go-ebpf-logger:latest \
119+ -f Dockerfile64.amd64 .
0 commit comments