-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (62 loc) · 2.86 KB
/
main.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
name: CI
on:
push:
jobs:
build-server:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- env:
DOCKER_IMAGE_NAME: "docker.pkg.github.com/hasadna/datacity-ckan-dgp/server"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HASADNA_K8S_DEPLOY_KEY: ${{ secrets.HASADNA_K8S_DEPLOY_KEY }}
run: |
echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u hasadna --password-stdin &&\
if docker pull "${DOCKER_IMAGE_NAME}:latest"; then
CACHE_FROM_ARG="--cache-from ${DOCKER_IMAGE_NAME}:latest"
else
CACHE_FROM_ARG=""
fi &&\
docker build $CACHE_FROM_ARG -t server . &&\
docker tag server "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" &&\
docker push "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" &&\
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
docker tag server "${DOCKER_IMAGE_NAME}:latest" &&\
docker push "${DOCKER_IMAGE_NAME}:latest" &&\
if ! git log -1 --pretty=format:"%s" | grep -- --no-deploy; then
cd `mktemp -d` &&\
echo "${HASADNA_K8S_DEPLOY_KEY}" > hasadna_k8s_deploy_key &&\
chmod 400 hasadna_k8s_deploy_key &&\
export GIT_SSH_COMMAND="ssh -i `pwd`/hasadna_k8s_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\
git clone [email protected]:hasadna/hasadna-k8s.git &&\
cd hasadna-k8s &&\
python update_yaml.py '{"ckanDgpServerImage":"'"${DOCKER_IMAGE_NAME}:${GITHUB_SHA}"'"}' apps/datacity/values-hasadna-auto-updated.yaml &&\
git config --global user.name "Datacity Ckan DGP CI" &&\
git config --global user.email "datacity-ckan-dgp-ci@localhost" &&\
git add apps/datacity/values-hasadna-auto-updated.yaml && git commit -m "automatic update of datacity ckan dgp server" &&\
git push origin master
fi
fi
build-db:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- env:
DOCKER_IMAGE_NAME: "docker.pkg.github.com/hasadna/datacity-ckan-dgp/datacity-ckan-dgp-db"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u hasadna --password-stdin &&\
if docker pull "${DOCKER_IMAGE_NAME}:latest"; then
CACHE_FROM_ARG="--cache-from ${DOCKER_IMAGE_NAME}:latest"
else
CACHE_FROM_ARG=""
fi &&\
docker build $CACHE_FROM_ARG -t db db &&\
docker tag db "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" &&\
docker push "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" &&\
echo "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" &&\
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
docker tag db "${DOCKER_IMAGE_NAME}:latest" &&\
docker push "${DOCKER_IMAGE_NAME}:latest" &&\
echo "${DOCKER_IMAGE_NAME}:latest"
fi