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 8
8
branches :
9
9
- master
10
10
11
+ env :
12
+ REGISTRY : ghcr.io
13
+ IMAGE_NAME : ${{ github.repository }}
14
+
11
15
jobs :
12
16
build :
13
17
name : Build
36
40
with :
37
41
version : latest
38
42
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
+ uses : actions/checkout@v3.0.0
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
+ uses : actions/checkout@v3.0.0
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@v2.1.0
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 5
5
tags :
6
6
- ' *'
7
7
8
+ env :
9
+ REGISTRY : ghcr.io
10
+ IMAGE_NAME : ${{ github.repository }}
11
+
8
12
jobs :
9
13
goreleaser :
10
14
runs-on : ubuntu-20.04
24
28
args : release --rm-dist
25
29
env :
26
30
GITHUB_TOKEN : ${{ secrets.GH_PUBLISH_SECRETS }}
31
+
32
+ image :
33
+ runs-on : ubuntu-20.04
34
+ steps :
35
+ - name : Checkout
36
+ uses : actions/checkout@v3.0.0
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 ubuntu:kinetic
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
4
4
cp bin/gaw /usr/local/bin
5
5
test-gh :
6
6
act -W pkg/data/ -j imageTest
7
+ image :
8
+ docker build .
You can’t perform that action at this time.
0 commit comments