forked from Fred78290/cert-manager-webhook-godaddy
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (173 loc) · 5.54 KB
/
ci.yaml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
name: cert-manager-godaddy
on:
push:
branches:
- '*'
tags:
- v*
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
REGISTRY: ${{ secrets.REGISTRY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache vendor
uses: actions/cache@v3
env:
cache-name: cache-vendor
with:
path: vendor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.mod') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Prepare
id: prep
run: |
TAG=pr
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Build with tag=${TAG}"
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: 1.20
- name: Build binary
shell: bash
run: make -e REGISTRY=$REGISTRY -e TAG="${{ steps.prep.outputs.tag }}" build-in-docker
# Directory created with a docker run having user root
- name: Fix directory owner
shell: bash
run: sudo chown -R $USER out vendor
- name: Output
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: binaries
path: out
if-no-files-found: error
test:
name: Test
env:
GODADDY_API_KEY: ${{ secrets.GODADDY_API_KEY }}
GODADDY_API_SECRET: ${{ secrets.GODADDY_API_SECRET }}
TEST_ZONE_NAME: ${{ secrets.TEST_ZONE_NAME }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
TAG=pr
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Build with tag=${TAG}"
- name: Cache vendor
uses: actions/cache@v3
env:
cache-name: cache-vendor
with:
path: vendor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('go.mod') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: fetch hack
shell: bash
run: ./scripts/fetch-test-binaries.sh
- name: test
shell: bash
run: ./scripts/test.sh
- name: Fix directory owner
shell: bash
run: sudo chown -R $USER vendor
sonarcloud:
if: startsWith(github.ref, 'refs/heads/')
name: SonarCloud
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Directory created with a docker run having user root
- name: Prepare SonarCloud
shell: bash
run: sudo chown -R $USER .scannerwork
deploy:
if: startsWith(github.ref, 'refs/tags/v')
needs: test
name: Deploy
runs-on: ubuntu-latest
env:
REGISTRY: ${{ secrets.REGISTRY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
TAG=pr
if [[ $GITHUB_REF == refs/tags/v* ]]; then
TAG=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Build with tag=${TAG}"
# echo ::set-env name=RELEASE_VERSION::${TAG}
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: 1.20
- name: Setup docker buildx
uses: docker/[email protected]
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: out
- name: Prepare docker buildx
shell: bash
run: |
docker buildx version;
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin;
docker buildx create --use
- name: Build docker image
shell: bash
run: |
make -e REGISTRY=$REGISTRY -e TAG="${{ steps.prep.outputs.tag }}" push-manifest
- name: Prepare Release
shell: bash
run: |
cp out/linux/amd64/cert-manager-godaddy cert-manager-godaddy-amd64
cp out/linux/arm64/cert-manager-godaddy cert-manager-godaddy-arm64
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.prep.outputs.tag }}
# release_name: Release ${{ steps.prep.outputs.tag }}
draft: false
files: |
cert-manager-godaddy-amd64
cert-manager-godaddy-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # You don't need to add this in secrets it's by default.