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+ env :
88+ GH_TOKEN : ${{ github.token }}
89+
90+ - name : Decide to push or not
91+ id : decide
92+ run : |
93+ if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
94+ echo "PUSH=true" >> $GITHUB_ENV
95+ else
96+ echo "PUSH=false" >> $GITHUB_ENV
97+ fi
98+
99+ - name : Build Image
100+ if : env.PUSH == 'false'
101+ run : |
102+ docker buildx build \
103+ --platform linux/amd64,linux/arm64 \
104+ --build-arg TARGETARCH=amd64 \
105+ --file Dockerfile \
106+ -t siddh34/go-ebpf-logger:latest \
107+ .
108+
109+ - name : Login to DockerHub
110+ if : env.PUSH == 'true'
111+ run : echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login -u "siddh34" --password-stdin
112+
113+ - name : Build & Push Docker images
114+ if : env.PUSH == 'true'
115+ run : |
116+ docker buildx build \
117+ --platform linux/amd64,linux/arm64 \
118+ --file Dockerfile \
119+ --push \
120+ -t siddh34/go-ebpf-logger:latest \
121+ .
0 commit comments