-
Notifications
You must be signed in to change notification settings - Fork 1.7k
160 lines (140 loc) · 5.24 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: deploy
on:
push:
branches:
- '**'
- '!dependabot/**'
tags:
- 'v*'
- 'scorecard-kuttl/v*'
pull_request:
branches: [ master ]
jobs:
check_docs_only:
name: check_docs_only
runs-on: ubuntu-22.04
outputs:
skip: ${{ steps.check_docs_only.outputs.skip }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: check_docs_only
# Since PR's are squashed prior to merging to the branch checked out (default branch),
# HEAD^ will resolve to the previous point in history.
run: |
REF="HEAD^"
[[ -z "${{ github.base_ref }}" ]] || REF=$(git show-ref ${{ github.base_ref }} | head -1 | cut -d' ' -f2)
echo "::set-output name=skip::$(.github/workflows/check-docs-only.sh $REF)"
# Job to test release steps. This will only create a release remotely if run on a tagged commit.
goreleaser:
name: goreleaser
needs: check_docs_only
# Run this job on a tag like 'vX.Y.Z' or on a branch or pull request with code changes.
if: startsWith(github.ref, 'refs/tags/v') || ( needs.check_docs_only.outputs.skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
runs-on: ubuntu-22.04
environment: deploy
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: gpg init
if: ${{ github.event_name != 'pull_request' }}
run: .ci/gpg/create-keyring.sh
env:
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
- name: release
run: |
if [[ $GITHUB_REF != refs/tags/v* ]]; then
export DRY_RUN=1
fi
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Job matrix for image builds. Only pushes if a tag with prefix "v" is present.
images:
name: images
needs: check_docs_only
# Run this job on a tag like 'vX.Y.Z' or on a branch or pull request with code changes.
if: startsWith(github.ref, 'refs/tags/v') || ( needs.check_docs_only.outputs.skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
runs-on: ubuntu-22.04
environment: deploy
strategy:
matrix:
id: ["operator-sdk", "helm-operator", "scorecard-test"]
steps:
- name: set up qemu
uses: docker/setup-qemu-action@v2
- name: set up buildx
uses: docker/setup-buildx-action@v3
- name: quay.io login
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
# Check out repo before tag step for script.
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: create tags
id: tags
run: |
IMG=quay.io/${{ github.repository_owner }}/${{ matrix.id }}
echo ::set-output name=tags::$(.github/workflows/get_image_tags.sh "$IMG" "v")
- name: build and push
uses: docker/build-push-action@v3
with:
file: ./images/${{ matrix.id }}/Dockerfile
context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# Push on tag, or master or latest branch push.
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/latest')) }}
tags: ${{ steps.tags.outputs.tags }}
# scorecard-test-kuttl image build job. Only pushes if a tag with prefix "scorecard-kuttl/v" is present.
image-scorecard-test-kuttl:
name: image-scorecard-test-kuttl
needs: check_docs_only
# Run this job on a tag like 'scorecard-kuttl/vX.Y.Z' or on a branch or pull request with code changes.
if: startsWith(github.ref, 'refs/tags/scorecard-kuttl/v') || ( needs.check_docs_only.outputs.skip != 'true' && !startsWith(github.ref, 'refs/tags/') )
runs-on: ubuntu-22.04
environment: deploy
steps:
- name: set up qemu
uses: docker/setup-qemu-action@v2
- name: set up buildx
uses: docker/setup-buildx-action@v3
- name: quay.io login
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
# Check out repo before tag step for script.
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: create tags
id: tags
run: |
IMG=quay.io/${{ github.repository_owner }}/scorecard-test-kuttl
echo ::set-output name=tags::$(.github/workflows/get_image_tags.sh "$IMG" "scorecard-kuttl/v")
- name: build and push
uses: docker/build-push-action@v3
with:
file: ./images/scorecard-test-kuttl/Dockerfile
context: .
# s390x is not supported by the scorecard-test-kuttl base image.
platforms: linux/amd64,linux/arm64,linux/ppc64le
# Push on tag, or master branch push.
push: ${{ (github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')) }}
tags: ${{ steps.tags.outputs.tags }}