-
Notifications
You must be signed in to change notification settings - Fork 71
130 lines (112 loc) · 4.97 KB
/
pr-build.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
name: spinnaker-operator
on:
push:
branches:
- master
- release-*
pull_request_review:
types: [submitted]
jobs:
build:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Fetch full history
run: git fetch --prune --tags --unshallow
- name: Set up Go 1.18.2
uses: actions/setup-go@v3
with:
go-version: 1.18.2
- name: Determine build type
id: build_type
run: |
echo "github.ref: ${{ github.ref }}"
echo "github.base_ref: ${{ github.base_ref }}"
echo "github.head_ref: ${{ github.head_ref }}"
echo "branch: $(git rev-parse --abbrev-ref HEAD)"
if [[ ${{github.event_name }} = "pull_request" ]] ; then branch_override=${{ github.head_ref }} ; fi
# On PRs to release branches, build RC releases for target release branch
if [[ ${{github.event_name }} = "pull_request" && "x${{ github.base_ref }}" =~ ^xrelease-* ]]
then
echo "Building release candidate"
build_type=rc
branch_override=${{ github.base_ref }}
registry=docker.io
else
echo "Building snapshot"
build_type=snapshot
registry=armory-docker-local.jfrog.io
fi
make_args="VERSION_TYPE=$build_type REGISTRY=$registry REGISTRY_ORG=armory BRANCH_OVERRIDE=$branch_override"
version=$(make version $make_args)
echo "Version: $version"
# Make sure the version can be used as a tag
git tag v$version
git tag -d v$version
echo "build_type=$build_type" >> $GITHUB_OUTPUT
echo "registry=$registry" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "make_args=$make_args" >> $GITHUB_OUTPUT
# We need to do this for at least a few versions so that we don't force
# users to manually fix the CRDs when migrating from v1beta1 to v1.
- name: Modify spinsvc CRD to assist with migration
uses: mikefarah/[email protected]
with:
cmd: yq -i '.spec.preserveUnknownFields = false' deploy/crds/spinnaker.io_spinnakerservices.yaml
- name: Build
run: |
go mod vendor && go mod tidy
make build ${{ steps.build_type.outputs.make_args }}
make docker-build ${{ steps.build_type.outputs.make_args }}
- name: Package
run: |
make docker-package ${{ steps.build_type.outputs.make_args }}
- name: Login to docker registry
run: |
if [[ ${{ steps.build_type.outputs.registry }} = "docker.io" ]]
then
echo "Logging in to dockerhub"
docker login -u ${{ secrets.DOCKERHUB_USER }} -p "${{ secrets.DOCKERHUB_PASSWORD }}" docker.io
else
echo "Logging in to jfrog"
docker login -u ${{ secrets.JFROG_USER }} -p "${{ secrets.JFROG_PASSWORD }}" armory-docker-local.jfrog.io
fi
- name: Push
run: |
make docker-push ${{ steps.build_type.outputs.make_args }}
- name: Push git tag
if: steps.build_type.outputs.build_type == 'rc'
run: |
git tag v${{ steps.build_type.outputs.version }}
git push origin v${{ steps.build_type.outputs.version }}
# Skipping integration test
# - uses: engineerd/[email protected]
# with:
# version: "v0.11.1"
# - name: Install load balancer
# if: steps.build_type.outputs.build_type == 'rc'
# run: |
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml
# kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
# kubectl apply -f integration_tests/kind/metallb-configmap.yaml
# until [ "$(kubectl get pods --all-namespaces --no-headers | grep -cEv '([0-9]+)/\1')" -ne 0 ]; do
# sleep 5s
# done
#
# - name: Run tests
# if: steps.build_type.outputs.build_type == 'rc'
# env:
# S3_BUCKET: ${{ secrets.INTEGRATION_TEST_S3_BUCKET }}
# AWS_ACCESS_KEY_ID: ${{ secrets.INTEGRATION_TEST_S3_USER }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.INTEGRATION_TEST_S3_PASSWORD }}
# AWS_DEFAULT_REGION: ${{ secrets.INTEGRATION_TEST_S3_BUCKET_REGION }}
# AWS_EC2_METADATA_DISABLED: true
# OPERATOR_IMAGE: ${{ steps.build_type.outputs.registry }}/armory/spinnaker-operator:${{ steps.build_type.outputs.version }}
# run: |
# kind load docker-image ${{ steps.build_type.outputs.registry }}/armory/spinnaker-operator:${{ steps.build_type.outputs.version }}
# halyard=$(cat halyard-version | head -1)
# export HALYARD_IMAGE="armory/halyard:$halyard"
# make integration-test