66 - ' **'
77 tags :
88 - ' v*'
9+ - ' scorecard-kuttl/v*'
910 pull_request :
1011 branches : [ master ]
1112
@@ -14,22 +15,25 @@ jobs:
1415 name : check_docs_only
1516 runs-on : ubuntu-18.04
1617 outputs :
17- should_skip_tests : ${{ steps.check_docs_only.outputs.skip-tests }}
18+ is_skip : ${{ steps.check_docs_only.outputs.skip-deploy }}
1819 steps :
1920 - uses : actions/checkout@v2
2021 with :
2122 fetch-depth : 0
2223 - 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.
2326 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)"
2730
2831 # Job to test release steps. This will only create a release remotely if run on a tagged commit.
2932 goreleaser :
3033 name : goreleaser
3134 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/') )
3337 runs-on : ubuntu-18.04
3438 environment : deploy
3539 steps :
@@ -51,23 +55,24 @@ jobs:
5155
5256 - name : release
5357 run : |
54- if [[ $GITHUB_REF != refs/tags/* ]]; then
58+ if [[ $GITHUB_REF != refs/tags/v * ]]; then
5559 export DRY_RUN=1
5660 fi
5761 make release
5862 env :
5963 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6064
61- # Job matrix for image builds.
65+ # Job matrix for image builds. Only pushes if a tag with prefix "v" is present.
6266 images :
6367 name : images
6468 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/') )
6671 runs-on : ubuntu-18.04
6772 environment : deploy
6873 strategy :
6974 matrix :
70- id : ["operator-sdk", "ansible-operator", "helm-operator", "scorecard-test", "scorecard-test-kuttl" ]
75+ id : ["operator-sdk", "ansible-operator", "helm-operator", "scorecard-test"]
7176 steps :
7277
7378 - name : set up qemu
@@ -84,35 +89,69 @@ jobs:
8489 password : ${{ secrets.QUAY_PASSWORD }}
8590 registry : quay.io
8691
92+ # Check out repo before tag step for script.
93+ - name : checkout
94+ uses : actions/checkout@v2
95+ with :
96+ fetch-depth : 0
97+
8798 - name : create tags
8899 id : tags
89100 run : |
90101 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 :
104122
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.
105138 - name : checkout
106139 uses : actions/checkout@v2
107140 with :
108141 fetch-depth : 0
109142
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+
110149 - name : build and push
111150 uses : docker/build-push-action@v2
112151 with :
113- file : ./images/${{ matrix.id }} /Dockerfile
152+ file : ./images/scorecard-test-kuttl /Dockerfile
114153 context : .
115154 # 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
117156 push : ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) )) }}
118157 tags : ${{ steps.tags.outputs.tags }}
0 commit comments