-
Notifications
You must be signed in to change notification settings - Fork 18
151 lines (147 loc) · 5.32 KB
/
xcube_workflow.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
name: Unittest and docker builds
on:
push:
release:
types: [published]
jobs:
unittest:
runs-on: ubuntu-latest
env:
NUMBA_DISABLE_JIT: 1
steps:
- uses: actions/checkout@v2
# Setup miniconda nd build env
- uses: conda-incubator/setup-miniconda@v2
with:
mamba-version: "*"
channels: conda-forge
activate-environment: xcube
environment-file: environment.yml
# Setup xcube
- name: setup-xcube
shell: bash -l {0}
run: |
conda info
conda list
python setup.py develop
# Run unittests
- name: unittest-xcube
shell: bash -l {0}
run: |
pip install pytest pytest-cov
mamba install -c conda-forge flask-testing moto requests-mock
pytest --cov=./ --cov-report=xml
- uses: codecov/codecov-action@v1
with:
verbose: true # optional (default = false)
build-docker-image:
runs-on: ubuntu-latest
# Only run if unittests succeed
needs: unittest
# Build the docker image and push to quay.io
name: build-docker-image
env:
APP_NAME: xcube
ORG_NAME: bcdev
steps:
- name: git-checkout
uses: actions/checkout@v2
# Strip the release tag from refs
- name: get-release-tag
id: release
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# Print some info
- name: info
id: info
run: |
echo "TAG: ${{ steps.release.outputs.tag }}"
echo "EVENT: ${{ github.event_name }}"
# Build and push docker image 'latest' to quay.io when the event is a 'push' and branch 'master'
- uses: mr-smithers-excellent/docker-build-push@v5
name: build-push-docker-image-latest
if: ${{ github.event_name == 'push' && steps.release.outputs.tag == 'master' }}
with:
image: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}
tags: master, latest
registry: quay.io
username: ${{ secrets.QUAY_DOCKER_REPO_USERNAME }}
password: ${{ secrets.QUAY_DOCKER_REPO_PASSWORD }}
# Build and push docker release to quay.io when the event is a 'release'
- uses: mr-smithers-excellent/docker-build-push@v5
name: build-push-docker-image-release
if: ${{ github.event_name == 'release' }}
with:
image: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}
tags: ${{ steps.release.outputs.tag }}
registry: quay.io
username: ${{ secrets.QUAY_DOCKER_REPO_USERNAME }}
password: ${{ secrets.QUAY_DOCKER_REPO_PASSWORD }}
update-version:
env:
PUSH: 0
APP_NAME: xcube
runs-on: ubuntu-latest
needs: build-docker-image
name: update-tag
steps:
- name: git-checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: bc-org/k8s-configs
token: ${{ secrets.XCUBE_GITHUB_K8S_CONFIGS_PAT }}
path: k8s
- name: get-release-tag
id: release
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: deployment-phase
id: deployment-phase
uses: bc-org/gha-determine-phase@v0.1
with:
event_name: ${{ github.event_name }}
tag: ${{ steps.release.outputs.tag }}
- name: get-hash
id: get-hash
run: |
HASH=$(skopeo inspect docker://quay.io/bcdev/${{ env.APP_NAME }}:${{ steps.release.outputs.tag }} | jq '.Digest')
if [[ "$HASH" == *"sha256"* ]]; then
echo ::set-output name=hash::$HASH
else
echo "No hash present. Using none as hash. This will use the version tag instead for deployment."
echo ::set-output name=hash::none
fi
- name: info
run: |
echo "Event: ${{ github.event_name }}"
echo "Deployment Stage: ${{ steps.deployment-phase.outputs.phase }}"
echo "Release Tag: ${{ steps.release.outputs.tag }}"
echo "Deployment Release Tag: ${{ steps.deployment-phase.outputs.tag }}"
echo "Deployment Digest: ${{ steps.get-hash.outputs.hash }}"
- name: set-version-tag-xcube-gen
uses: bc-org/update-application-version-tags@main
with:
app: ${{ env.APP_NAME }}
phase: ${{ steps.deployment-phase.outputs.phase }}
delimiter: ' '
tag: ${{ steps.deployment-phase.outputs.tag }}
hash: ${{ steps.get-hash.outputs.hash }}
working-directory: "./k8s/xcube-gen/helm"
- name: cat-result
working-directory: "./k8s/xcube-gen/helm"
run: |
head values-dev.yaml
head values-stage.yaml
head values-prod.yaml
- name: Pushes to another repository
# Don't run if run locally and should be ignored
if: ${{ steps.deployment-phase.outputs.phase != 'ignore' && !env.ACT }}
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.XCUBE_GITHUB_K8S_CONFIGS_PAT }}
with:
source-directory: 'k8s'
destination-github-username: 'bc-org'
destination-repository-name: 'k8s-configs'
user-email: bcdev@brockmann-consult.de
target-branch: main
commit-message: ${{ github.event.release }}. Set version to ${{ steps.release.outputs.tag }}