File tree Expand file tree Collapse file tree 4 files changed +97
-0
lines changed Expand file tree Collapse file tree 4 files changed +97
-0
lines changed Original file line number Diff line number Diff line change 88 branches :
99 - master
1010
11+ env :
12+ REGISTRY : ghcr.io
13+ IMAGE_NAME : ${{ github.repository }}
14+
1115jobs :
1216 build :
1317 name : Build
3640 with :
3741 version : latest
3842 args : release --skip-publish --rm-dist
43+
44+ build-image :
45+ name : Build Image
46+ runs-on : ubuntu-20.04
47+ if : github.ref != 'refs/heads/master'
48+ steps :
49+ - name : Check out code
50+ 51+ - name : Build Image
52+ run : |
53+ make image
54+ image :
55+ name : Publish Image
56+ runs-on : ubuntu-20.04
57+ if : github.ref == 'refs/heads/master'
58+ steps :
59+ - name : Checkout
60+ 61+ - name : Setup Docker buildx
62+ uses : docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
63+ - name : Log into registry ${{ env.REGISTRY }}
64+ if : github.event_name != 'pull_request'
65+ uses : docker/login-action@28219f9b04b4f3f62068d7b6ce6ca5b26e35336c
66+ with :
67+ registry : ${{ env.REGISTRY }}
68+ username : ${{ github.actor }}
69+ password : ${{ secrets.GH_PUBLISH_SECRETS }}
70+ - name : Extract Docker metadata
71+ id : meta
72+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
73+ with :
74+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+ - name : Build and push Docker image
76+ id : build-and-push
77+ uses : docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
78+ with :
79+ context : .
80+ push : ${{ github.event_name != 'pull_request' }}
81+ tags : ${{ steps.meta.outputs.tags }}
82+ labels : ${{ steps.meta.outputs.labels }}
83+ cache-from : type=gha
84+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 55 tags :
66 - ' *'
77
8+ env :
9+ REGISTRY : ghcr.io
10+ IMAGE_NAME : ${{ github.repository }}
11+
812jobs :
913 goreleaser :
1014 runs-on : ubuntu-20.04
2428 args : release --rm-dist
2529 env :
2630 GITHUB_TOKEN : ${{ secrets.GH_PUBLISH_SECRETS }}
31+
32+ image :
33+ runs-on : ubuntu-20.04
34+ steps :
35+ - name : Checkout
36+ 37+ - name : Setup Docker buildx
38+ uses : docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
39+ - name : Log into registry ${{ env.REGISTRY }}
40+ if : github.event_name != 'pull_request'
41+ uses : docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
42+ with :
43+ registry : ${{ env.REGISTRY }}
44+ username : ${{ github.actor }}
45+ password : ${{ secrets.GH_PUBLISH_SECRETS }}
46+ - name : Extract Docker metadata
47+ id : meta
48+ uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
49+ with :
50+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+ - name : Build and push Docker image
52+ id : build-and-push
53+ uses : docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
54+ with :
55+ context : .
56+ push : ${{ github.event_name != 'pull_request' }}
57+ tags : ${{ steps.meta.outputs.tags }}
58+ labels : ${{ steps.meta.outputs.labels }}
59+ cache-from : type=gha
60+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 1+ FROM golang:1.19 as builder
2+
3+ WORKDIR /workspace
4+ COPY . .
5+ RUN go mod download
6+ RUN CGO_ENABLE=0 go build -ldflags "-w -s" -o gaw
7+
8+ FROM alpine:3.10
9+
10+ LABEL "repository" ="https://github.com/linuxsuren/github-action-workflow"
11+ LABEL "homepage" ="https://github.com/linuxsuren/github-action-workflow"
12+
13+ COPY --from=builder /workspace/gaw /usr/local/bin/gaw
14+
15+ CMD ["gaw" ]
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ copy: build
44 cp bin/gaw /usr/local/bin
55test-gh :
66 act -W pkg/data/ -j imageTest
7+ image :
8+ docker build .
You can’t perform that action at this time.
0 commit comments