-
Notifications
You must be signed in to change notification settings - Fork 7
102 lines (102 loc) · 5.19 KB
/
Copy pathci.yml
File metadata and controls
102 lines (102 loc) · 5.19 KB
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
name: CI
on:
push:
paths-ignore:
- '**.md'
- '**.png'
env:
DOCKER_APP_IMAGE_NAME: "ghcr.io/hasadna/open-bus-stride-db/open-bus-stride-db"
DOCKER_BACKUP_IMAGE_NAME: "ghcr.io/hasadna/open-bus-stride-db/open-bus-stride-db-backup"
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ format('{0}:{1}', env.DOCKER_APP_IMAGE_NAME, github.sha) }}
${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && format('{0}:latest', env.DOCKER_APP_IMAGE_NAME) || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - uses: docker/build-push-action@v6
# with:
# context: backup
# push: true
# tags: |
# ${{ format('{0}:{1}', env.DOCKER_BACKUP_IMAGE_NAME, github.sha) }}
# ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && format('{0}:latest', env.DOCKER_BACKUP_IMAGE_NAME) || '' }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
- run: |
set -euo pipefail
docker run -e POSTGRES_PASSWORD=123456 -p 5432:5432 -v `pwd`/.data/db:/var/lib/postgresql/data -d postgres:14
sleep 5
docker run --network host -e SQLALCHEMY_URL=postgresql://postgres:123456@localhost ${DOCKER_APP_IMAGE_NAME}:${{ github.sha }}
docker tag ${DOCKER_APP_IMAGE_NAME}:${{ github.sha }} app
docker build -t docgen -f docgen.Dockerfile .
docker run --network host -e SQLALCHEMY_URL=postgresql://postgres:123456@localhost \
-v "`pwd`/docgen_output:/output" \
--entrypoint python docgen bin/docgen.py /output
git config user.name "open-bus-stride-db-ci"
git config user.email "open-bus-stride-db-ci@localhost"
if ! diff docgen_output/DATA_MODEL.md ./DATA_MODEL.md || ! diff docgen_output/dbschema.png ./dbschema.png; then
cp -f docgen_output/DATA_MODEL.md ./DATA_MODEL.md
cp -f docgen_output/dbschema.png ./dbschema.png
git add ./DATA_MODEL.md && git add ./dbschema.png
git commit -m "automatic update of the data model documentation"
git push
fi
- if: ${{ github.ref == 'refs/heads/main' }}
env:
HASADNA_K8S_DEPLOY_KEY: ${{ secrets.HASADNA_K8S_DEPLOY_KEY }}
SIRI_ETL_DEPLOY_KEY: ${{ secrets.SIRI_ETL_DEPLOY_KEY }}
STRIDE_API_DEPLOY_KEY: ${{ secrets.STRIDE_API_DEPLOY_KEY }}
STRIDE_ETL_DEPLOY_KEY: ${{ secrets.STRIDE_ETL_DEPLOY_KEY }}
run: |
set -euo pipefail
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 git@github.com:hasadna/hasadna-k8s.git
cd hasadna-k8s
python update_yaml.py '{"strideDbAppImage":"'"${DOCKER_APP_IMAGE_NAME}:${GITHUB_SHA}"'"}' apps/openbus/values-hasadna-auto-updated.yaml
git config --global user.name "Open Bus Stride DB CI"
git config --global user.email "open-bus-stride-db-ci@localhost"
git add apps/openbus/values-hasadna-auto-updated.yaml && git commit -m "automatic update of open bus stride db"
git push origin master
echo "${SIRI_ETL_DEPLOY_KEY}" > siri_etl_deploy_key
chmod 400 siri_etl_deploy_key
export GIT_SSH_COMMAND="ssh -i `pwd`/siri_etl_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
git clone git@github.com:hasadna/open-bus-siri-etl.git
cd open-bus-siri-etl
bin/update_stride_db_dependencies.py "${GITHUB_SHA}"
git commit -m "automatic update of open bus stride db dependencies"
git push origin main
echo "${STRIDE_API_DEPLOY_KEY}" > stride_api_deploy_key
chmod 400 stride_api_deploy_key
export GIT_SSH_COMMAND="ssh -i `pwd`/stride_api_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
git clone git@github.com:hasadna/open-bus-stride-api.git
cd open-bus-stride-api
bin/update_stride_db_dependencies.py "${GITHUB_SHA}"
git commit -m "automatic update of open bus stride db dependencies"
git push origin main
echo "${STRIDE_ETL_DEPLOY_KEY}" > stride_etl_deploy_key
chmod 400 stride_etl_deploy_key
export GIT_SSH_COMMAND="ssh -i `pwd`/stride_etl_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
git clone git@github.com:hasadna/open-bus-stride-etl.git
cd open-bus-stride-etl
echo "${GITHUB_SHA}" > stride-db-latest-commit.txt
git add stride-db-latest-commit.txt
git commit -m "automatic update of open bus stride db dependencies"
git push origin main
fi