This repository was archived by the owner on Jul 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
151 lines (125 loc) · 4.23 KB
/
main.yml
File metadata and controls
151 lines (125 loc) · 4.23 KB
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
name: CI
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
env:
KUBEBUILDER_VERSION: 2.3.1
jobs:
build:
name: Build
container:
image: golang:1.15
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Add kubebuilder
run: |
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${{env.KUBEBUILDER_VERSION}}/kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz > kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
tar -xvf kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64.tar.gz
mv kubebuilder_${{env.KUBEBUILDER_VERSION}}_linux_amd64 /usr/local/kubebuilder
- name: Vet and Build
run: make manager
- name: Test
run: make test
- name: Coverage
uses: codecov/codecov-action@v1
with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./cover.out
# flags: unittests # optional
name: externalsecret-operator
fail_ci_if_error: true
docker:
name: Docker
runs-on: ubuntu-latest
needs: build
steps:
- name: Prepare
id: prep
run: |
IS_LATEST=false
IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
DOCKER_IMAGE=ghcr.io/${IMAGE_REPOSITORY}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
IS_LATEST=true
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [[ $GITHUB_REF == refs/heads/master ]]; then
IS_LATEST=true
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "$IS_LATEST" = true ] ; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
PUSH_IMAGE=true
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
# If this is both a pull request and a fork, then don't push the image
if [[ ${{ github.event_name }} == pull_request ]]; then
if [[ $REPO_FULL_NAME != ${{ github.repository }} ]]; then
PUSH_IMAGE=false
fi
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=push_image::$PUSH_IMAGE
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Packages
id: docker-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
if: ${{ steps.prep.outputs.push_image == 'true' }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ${{ steps.prep.outputs.tags }}
push: ${{ steps.prep.outputs.push_image }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
helm:
name: Helm
container:
image: golang:1.15
runs-on: ubuntu-latest
needs: docker
steps:
- uses: actions/checkout@v2
- name: Test Helm
run: echo "Helm WIP"