forked from jlaunonen/kirppu
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (89 loc) · 2.87 KB
/
cicd.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
name: cicd
on:
push:
branches:
- development
- master
pull_request:
branches:
- development
- master
jobs:
test:
runs-on: ubuntu-20.04
env:
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
steps:
- uses: actions/checkout@v1
- uses: docker/setup-buildx-action@v1
- run: docker-compose -f docker-compose.test.yml up --exit-code-from test
build:
runs-on: ubuntu-20.04
env:
SKAFFOLD_DEFAULT_REPO: ghcr.io/con2
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- uses: pairity/setup-cd-tools@30acb848f9ff747aff4810dac40c5cc0971f485d
with:
skaffold: '1.20.0'
- uses: docker/login-action@v1
if: ${{ github.event_name == 'push' }}
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- uses: docker/setup-buildx-action@v1
- id: build
run: |
python3 -m pip install emskaffolden
# Do not push to registry on pull request events
if [ "${{ github.event_name }}" = pull_request ]; then
EMSKAFFOLDEN_ENV=pull_request
else
EMSKAFFOLDEN_ENV=default
fi
emskaffolden -E "$EMSKAFFOLDEN_ENV" -- build --file-output build.json
echo "::set-output name=build_json::$(base64 -w 0 < build.json)"
outputs:
build_json: ${{ steps.build.outputs.build_json }}
# TODO DRY
deploy_staging:
runs-on: self-hosted
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- uses: pairity/setup-cd-tools@30acb848f9ff747aff4810dac40c5cc0971f485d
with:
kubectl: '1.20.4'
skaffold: '1.20.0'
- uses: docker/setup-buildx-action@v1
- run: |
python3 -m pip install emskaffolden
base64 -d <<< "${{ needs.build.outputs.build_json }}" > build.json
emskaffolden -E staging -- deploy -n kirppu-staging -a build.json
deploy_production:
runs-on: self-hosted
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- uses: pairity/setup-cd-tools@30acb848f9ff747aff4810dac40c5cc0971f485d
with:
kubectl: '1.20.4'
skaffold: '1.20.0'
- uses: docker/setup-buildx-action@v1
- run: |
python3 -m pip install emskaffolden
base64 -d <<< "${{ needs.build.outputs.build_json }}" > build.json
emskaffolden -E production -- deploy -n kirppu -a build.json