-
Notifications
You must be signed in to change notification settings - Fork 20
156 lines (151 loc) · 5.62 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
152
153
154
155
156
name: Unittest and docker builds
on:
push:
release:
types: [published]
env:
APP_NAME: xcube
ORG_NAME: bcdev
IMG_REG_NAME: quay.io
jobs:
unittest:
runs-on: ubuntu-latest
env:
NUMBA_DISABLE_JIT: 1
steps:
- uses: actions/checkout@v2
# Setup miniconda build env
- uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.4.8-0'
environment-file: environment.yml
init-shell: >-
bash
cache-environment: true
post-cleanup: 'all'
# 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
pytest --cov=./ --cov-report=xml
- uses: codecov/codecov-action@v1
with:
verbose: true # optional (default = false)
build-docker-image:
runs-on: ubuntu-latest
# Build the docker image and push to quay.io
name: build-docker-image
# Only run if unittests succeed
needs: unittest
steps:
- name: git-checkout
uses: actions/checkout@v2
# Determine release tag from git ref
- 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: ${{ env.IMG_REG_NAME }}
username: ${{ secrets.IMG_REG_USERNAME }}
password: ${{ secrets.IMG_REG_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: ${{ env.IMG_REG_NAME }}
username: ${{ secrets.IMG_REG_USERNAME }}
password: ${{ secrets.IMG_REG_PASSWORD }}
update-version:
runs-on: ubuntu-latest
needs: build-docker-image
name: update-xcube-tag
steps:
- name: Get installation token
id: get_installation_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.TOKEN_PROVIDER_APP_ID }}
private_key: ${{ secrets.TOKEN_PROVIDER_KEY }}
repository: bc-org/k8s-configs
# the installationId of the GitHub app we are using
installationId: 36950178
- name: git-checkout
uses: actions/checkout@v2
- name: checkout-k8s
run: |
git clone https://x-access-token:${{ steps.get_installation_token.outputs.token }}@github.com/bc-org/k8s-configs.git
mv k8s-configs 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://${{ env.IMG_REG_NAME }}/${{ env.ORG_NAME }}/${{ 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 }}
run: |
cd ./k8s
git config user.name github-actions
git config user.email github-actions@github.com
git commit -am "${{ github.event.release }}. Set version to ${{ steps.release.outputs.tag }}."
git remote set-url origin https://x-access-token:${{ steps.get_installation_token.outputs.token }}@github.com/bc-org/k8s-configs.git
git push origin main