1
+ name : Build-PullRequest
2
+
3
+ on :
4
+ issue_comment :
5
+ types : [created]
6
+ env :
7
+ FB_IMAGE : fluent-bit:latest
8
+ OP_IMAGE : fluentbit-operator:latest
9
+
10
+ jobs :
11
+ push-check-custom :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - name : acknowledge deployment request to commenter
15
+ id : check
16
+ uses : khan/pull-request-comment-trigger@master
17
+ with :
18
+ trigger : " /push-custom-image"
19
+ reaction : rocket
20
+ env :
21
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
22
+ outputs :
23
+ triggered : ${{ steps.check.outputs.triggered }}
24
+
25
+ push-check-default :
26
+ runs-on : ubuntu-latest
27
+ steps :
28
+ - name : acknowledge deployment request to commenter
29
+ id : check
30
+ uses : khan/pull-request-comment-trigger@master
31
+ with :
32
+ trigger : " /push-image"
33
+ reaction : rocket
34
+ env :
35
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
36
+ outputs :
37
+ triggered : ${{ steps.check.outputs.triggered }}
38
+
39
+ build-and-push :
40
+ if : ${{ needs.push-check-custom.outputs.triggered == 'true' || needs.push-check-default.outputs.triggered == 'true'}}
41
+ runs-on : ubuntu-latest
42
+ needs :
43
+ - push-check-custom
44
+ - push-check-default
45
+ steps :
46
+ - name : get pull request ref
47
+ id : get_pull_request_ref
48
+
49
+ with :
50
+ route : GET /repos/:repository/pulls/:issue_id
51
+ repository : ${{ github.repository }}
52
+ issue_id : ${{ github.event.issue.number }}
53
+ env :
54
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
55
+ - uses : actions/checkout@v2
56
+ with :
57
+ repository : ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
58
+ ref : ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }}
59
+ - name : Docker login
60
+ uses : azure/docker-login@v1
61
+ with :
62
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
63
+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
64
+ - name : Set up Docker Buildx
65
+ id : buildx
66
+ uses : docker/setup-buildx-action@v1
67
+ - name : Custom image build and push
68
+ if : needs.push-check-custom.outputs.triggered == 'true'
69
+ run : |
70
+ echo "use buildx to build"
71
+ make build-fb -e FB_IMG=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.FB_IMAGE }}
72
+ make build-op -e OP_IMG=${{ secrets.DOCKERHUB_USERNAME }}/${{ env.OP_IMAGE }}
73
+ - name : Kubesphere image build and push
74
+ if : needs.push-check-default.outputs.triggered == 'true'
75
+ run : |
76
+ echo "use buildx to build"
77
+ make build-fb -e FB_IMG=kubesphere/${{ env.FB_IMAGE }}
78
+ make build-op -e OP_IMG=kubesphere/${{ env.OP_IMAGE }}
79
+ - name : Create comment if custom image build
80
+ if : needs.push-check-custom.outputs.triggered == 'true'
81
+ uses : peter-evans/create-or-update-comment@v1
82
+ with :
83
+ issue-number : ${{ github.event.issue.number }}
84
+ body : |
85
+ Congratulations! The image of this pr is pushed.
86
+ See ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.FB_IMAGE }} and ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.OP_IMAGE }}.
87
+ - name : Create comment if kubesphere image build
88
+ if : needs.push-check-default.outputs.triggered == 'true'
89
+ uses : peter-evans/create-or-update-comment@v1
90
+ with :
91
+ issue-number : ${{ github.event.issue.number }}
92
+ body : |
93
+ Congratulations! The image of this pr is pushed.
94
+ See kubesphere/${{ env.FB_IMAGE }} and kubesphere/${{ env.OP_IMAGE }}.
0 commit comments