-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (144 loc) · 5.23 KB
/
github-runner-provisioner.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
name: "GitHub Runner Provisioner: Tests, Builds, Deployments"
on:
pull_request:
paths:
- .github/workflows/github-runner-provisioner.yaml
- github-runner-provisioner/**
- '!**/*.md'
push:
branches:
- '**'
paths-ignore:
- '**/*.md'
jobs:
go_test:
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: FAKE_TOKEN
CODEMAGIC_TOKEN: FAKE_TOKEN
WEBHOOK_TOKEN: FAKE_TOKEN
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Run tests
run: |
cd github-runner-provisioner
make go-unit-tests
mock_traffic_test:
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GRP_GITHUB_TOKEN }}
CODEMAGIC_TOKEN: FAKE_TOKEN
WEBHOOK_TOKEN: FAKE_TOKEN
AWS_ACCESS_KEY_ID: ${{ secrets.GRP_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GRP_AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- run: cd github-runner-provisioner
- name: Build for Test
uses: docker/build-push-action@v5
with:
file: "github-runner-provisioner/Dockerfile"
platforms: linux/amd64
push: false
tags: |
datawiredev/github-runner-provisioner:${{ github.sha }}
outputs: type=docker, dest=/tmp/github-runner-provisioner.tar
cache-from: |
type=gha,scope=refs/heads/main
type=gha,scope=github-runner-provisioner-${{github.ref}}
cache-to: type=gha,mode=max,scope=github-runner-provisioner-${{github.ref}}
- name: Test CodeMagic
run: |
cd github-runner-provisioner
docker load --input /tmp/github-runner-provisioner.tar
docker run -d --name=github-runner-provisioner-codemagic -p 8080:8080 \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
-e CODEMAGIC_TOKEN=${CODEMAGIC_TOKEN} \
-e WEBHOOK_TOKEN=${WEBHOOK_TOKEN} \
-e USE_CODEMAGIC="true" \
datawiredev/github-runner-provisioner:${{ github.sha }}
make test-macOS-arm64
docker stop github-runner-provisioner-codemagic
echo
echo "Container logs:"
docker logs github-runner-provisioner-codemagic
echo
if [ "$(cat /tmp/test-macOS-arm64)" != "200" ]; then
echo "Test failed"
exit 1
fi
echo "Test Successful"
- name: Test AWS
run: |
cd github-runner-provisioner
docker load --input /tmp/github-runner-provisioner.tar
docker run -d --name=github-runner-provisioner-aws -p 8080:8080 \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
-e CODEMAGIC_TOKEN=${CODEMAGIC_TOKEN} \
-e WEBHOOK_TOKEN=${WEBHOOK_TOKEN} \
-e USE_CODEMAGIC="false" \
-e AWS_REGION="us-east-1" \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
datawiredev/github-runner-provisioner:${{ github.sha }}
make test-runners
docker stop github-runner-provisioner-aws
echo
echo "Container logs:"
docker logs github-runner-provisioner-aws
echo
if [ $(cat /tmp/test-ubuntu-arm64) != "200" ] || [ $(cat /tmp/test-macOS-arm64) != "200" ]; then
echo "Test failed"
exit 1
fi
echo "Test Successful"
build:
runs-on: ubuntu-22.04
needs: [go_test, mock_traffic_test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: cd github-runner-provisioner
- name: Build and push
uses: docker/build-push-action@v5
with:
file: "github-runner-provisioner/Dockerfile"
platforms: linux/amd64
push: true
tags: |
datawiredev/github-runner-provisioner:${{ github.sha }}
cache-from: |
type=gha,scope=refs/heads/main
type=gha,scope=github-runner-provisioner-${{github.ref}}
cache-to: type=gha,mode=max,scope=github-runner-provisioner-${{github.ref}}
deploy:
runs-on: ubuntu-22.04
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GRP_GITHUB_TOKEN }}
- name: Update Kustomize
env:
INFRA_ACTIONS_SHA: ${{ github.sha }}
run: |
cd github-runner-provisioner
envsubst < kustomization.yaml.in > kustomization.yaml
git config user.email "[email protected]"
git config user.name "d6e-automaton"
git add -A
git status
cat kustomization.yaml
echo "Updating manifests with image version ${INFRA_ACTIONS_SHA} and pushing to branch ${branch}"
git commit -m "Deploying updated manifest to ${INFRA_ACTIONS_SHA} [skip ci]"
git push --set-upstream origin ${branch}