6
6
- ' **'
7
7
tags :
8
8
- ' v*'
9
+ - ' scorecard-kuttl/v*'
9
10
pull_request :
10
11
branches : [ master ]
11
12
@@ -14,22 +15,25 @@ jobs:
14
15
name : check_docs_only
15
16
runs-on : ubuntu-18.04
16
17
outputs :
17
- should_skip_tests : ${{ steps.check_docs_only.outputs.skip-tests }}
18
+ is_skip : ${{ steps.check_docs_only.outputs.skip-deploy }}
18
19
steps :
19
20
- uses : actions/checkout@v2
20
21
with :
21
22
fetch-depth : 0
22
23
- id : check_docs_only
24
+ # Since PR's are squashed prior to merging to the branch checked out (default branch),
25
+ # HEAD^ will resolve to the previous point in history.
23
26
run : |
24
- REPO_MASTER_REF=$(git show-ref ${{ github.base_ref }} | head -1 | cut -d' ' -f2)
25
- echo "::set-output name=skip-tests::$(hack/ci/check-doc-only-update.sh $REPO_MASTER_REF)"
26
-
27
+ REF="HEAD^"
28
+ [[ -z "${{ github.base_ref }}" ]] || REF=$(git show-ref ${{ github.base_ref }} | head -1 | cut -d' ' -f2)
29
+ echo "::set-output name=skip-deploy::$(hack/ci/check-doc-only-update.sh $REF)"
27
30
28
31
# Job to test release steps. This will only create a release remotely if run on a tagged commit.
29
32
goreleaser :
30
33
name : goreleaser
31
34
needs : check_docs_only
32
- if : needs.check_docs_only.outputs.should_skip_tests != 'true'
35
+ # Run this job on a tag like 'vX.Y.Z' or on a branch or pull request with code changes.
36
+ if : startsWith(github.ref, 'refs/tags/v') || ( needs.check_docs_only.outputs.is_skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
33
37
runs-on : ubuntu-18.04
34
38
environment : deploy
35
39
steps :
@@ -51,23 +55,24 @@ jobs:
51
55
52
56
- name : release
53
57
run : |
54
- if [[ $GITHUB_REF != refs/tags/* ]]; then
58
+ if [[ $GITHUB_REF != refs/tags/v * ]]; then
55
59
export DRY_RUN=1
56
60
fi
57
61
make release
58
62
env :
59
63
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60
64
61
- # Job matrix for image builds.
65
+ # Job matrix for image builds. Only pushes if a tag with prefix "v" is present.
62
66
images :
63
67
name : images
64
68
needs : check_docs_only
65
- if : needs.check_docs_only.outputs.should_skip_tests != 'true'
69
+ # Run this job on a tag like 'vX.Y.Z' or on a branch or pull request with code changes.
70
+ if : startsWith(github.ref, 'refs/tags/v') || ( needs.check_docs_only.outputs.is_skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
66
71
runs-on : ubuntu-18.04
67
72
environment : deploy
68
73
strategy :
69
74
matrix :
70
- id : ["operator-sdk", "ansible-operator", "helm-operator", "scorecard-test", "scorecard-test-kuttl" ]
75
+ id : ["operator-sdk", "ansible-operator", "helm-operator", "scorecard-test"]
71
76
steps :
72
77
73
78
- name : set up qemu
@@ -84,35 +89,69 @@ jobs:
84
89
password : ${{ secrets.QUAY_PASSWORD }}
85
90
registry : quay.io
86
91
92
+ # Check out repo before tag step for script.
93
+ - name : checkout
94
+ uses : actions/checkout@v2
95
+ with :
96
+ fetch-depth : 0
97
+
87
98
- name : create tags
88
99
id : tags
89
100
run : |
90
101
IMG=quay.io/${{ github.repository_owner }}/${{ matrix.id }}
91
- if [[ $GITHUB_REF == refs/tags/* ]]; then
92
- TAG=${GITHUB_REF#refs/tags/}
93
- MAJOR_MINOR=${TAG%.*}
94
- echo ::set-output name=tags::${IMG}:${TAG},${IMG}:${MAJOR_MINOR}
95
-
96
- elif [[ $GITHUB_REF == refs/heads/* ]]; then
97
- TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
98
- echo ::set-output name=tags::${IMG}:${TAG}
99
-
100
- elif [[ $GITHUB_REF == refs/pull/* ]]; then
101
- TAG=pr-${{ github.event.number }}
102
- echo ::set-output name=tags::${IMG}:${TAG}
103
- fi
102
+ echo ::set-output name=tags::$(.github/workflows/get_image_tags.sh "$IMG" "v")
103
+
104
+ - name : build and push
105
+ uses : docker/build-push-action@v2
106
+ with :
107
+ file : ./images/${{ matrix.id }}/Dockerfile
108
+ context : .
109
+ platforms : linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
110
+ push : ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }}
111
+ tags : ${{ steps.tags.outputs.tags }}
112
+
113
+ # scorecard-test-kuttl image build job. Only pushes if a tag with prefix "scorecard-kuttl/v" is present.
114
+ image-scorecard-test-kuttl :
115
+ name : image-scorecard-test-kuttl
116
+ needs : check_docs_only
117
+ # Run this job on a tag like 'scorecard-kuttl/vX.Y.Z' or on a branch or pull request with code changes.
118
+ if : startsWith(github.ref, 'refs/tags/scorecard-kuttl/v') || ( needs.check_docs_only.outputs.is_skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
119
+ runs-on : ubuntu-18.04
120
+ environment : deploy
121
+ steps :
104
122
123
+ - name : set up qemu
124
+ uses : docker/setup-qemu-action@v1
125
+
126
+ - name : set up buildx
127
+ uses : docker/setup-buildx-action@v1
128
+
129
+ - name : quay.io login
130
+ if : github.event_name != 'pull_request'
131
+ uses : docker/login-action@v1
132
+ with :
133
+ username : ${{ secrets.QUAY_USERNAME }}
134
+ password : ${{ secrets.QUAY_PASSWORD }}
135
+ registry : quay.io
136
+
137
+ # Check out repo before tag step for script.
105
138
- name : checkout
106
139
uses : actions/checkout@v2
107
140
with :
108
141
fetch-depth : 0
109
142
143
+ - name : create tags
144
+ id : tags
145
+ run : |
146
+ IMG=quay.io/${{ github.repository_owner }}/scorecard-test-kuttl
147
+ echo ::set-output name=tags::$(.github/workflows/get_image_tags.sh "$IMG" "scorecard-kuttl/v")
148
+
110
149
- name : build and push
111
150
uses : docker/build-push-action@v2
112
151
with :
113
- file : ./images/${{ matrix.id }} /Dockerfile
152
+ file : ./images/scorecard-test-kuttl /Dockerfile
114
153
context : .
115
154
# s390x is not supported by the scorecard-test-kuttl base image.
116
- platforms : linux/amd64,linux/arm64,linux/ppc64le${{ matrix.id != 'scorecard-test-kuttl' && ',linux/s390x' || '' }}
155
+ platforms : linux/amd64,linux/arm64,linux/ppc64le
117
156
push : ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }}
118
157
tags : ${{ steps.tags.outputs.tags }}
0 commit comments