Skip to content

automatic update of open bus stride db dependencies #140

automatic update of open bus stride db dependencies

automatic update of open bus stride db dependencies #140

Workflow file for this run

name: CI
on:
push:
jobs:
ci:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- env:
DOCKER_APP_IMAGE_NAME: "docker.pkg.github.com/hasadna/open-bus-siri-etl/open-bus-siri-etl"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HASADNA_K8S_DEPLOY_KEY: ${{ secrets.HASADNA_K8S_DEPLOY_KEY }}
OPEN_BUS_PIPELINES_DEPLOY_KEY: ${{ secrets.OPEN_BUS_PIPELINES_DEPLOY_KEY }}
run: |
python3 -m pip install ruamel.yaml.clib==0.2.6 ruamel.yaml==0.17.21 &&\
bin/validate_airflow_yaml.py airflow.yaml &&\
OPEN_BUS_SIRI_ETL_ROOTDIR="$(pwd)" &&\
echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u hasadna --password-stdin &&\
if docker pull "${DOCKER_APP_IMAGE_NAME}:latest"; then
CACHE_FROM_ARG="--cache-from ${DOCKER_APP_IMAGE_NAME}:latest"
else
CACHE_FROM_ARG=""
fi &&\
docker build $CACHE_FROM_ARG -t app . &&\
docker tag app "${DOCKER_APP_IMAGE_NAME}:${GITHUB_SHA}" &&\
docker push "${DOCKER_APP_IMAGE_NAME}:${GITHUB_SHA}" &&\
docker run --rm --name stride-db -e POSTGRES_PASSWORD=123456 -p 5432:5432 -d postgres:13 &&\
sleep 2 &&\
docker run \
--network host \
-e SQLALCHEMY_URL=postgresql://postgres:123456@localhost \
--rm --name stride-db-migrations \
`cat open-bus-stride-db-docker-image.txt` &&\
docker run \
--network host \
-e SQLALCHEMY_URL=postgresql://postgres:123456@localhost \
-e DEBUG=yes \
-v `pwd`:/srv --entrypoint bash app -c "pip install -r tests/requirements.txt && pytest" &&\
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
docker tag app "${DOCKER_APP_IMAGE_NAME}:latest" &&\
docker push "${DOCKER_APP_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 '{"siriEtlImage":"'"${DOCKER_APP_IMAGE_NAME}:${GITHUB_SHA}"'"}' apps/openbus/values-hasadna-auto-updated.yaml &&\
git config --global user.name "Open Bus Siri ETL CI" &&\
git config --global user.email "open-bus-siri-etl-ci@localhost" &&\
git add apps/openbus/values-hasadna-auto-updated.yaml && git commit -m "automatic update of open bus siri etl" &&\
git push origin master &&\
echo "${OPEN_BUS_PIPELINES_DEPLOY_KEY}" > open_bus_pipelines_deploy_key &&\
chmod 400 open_bus_pipelines_deploy_key &&\
export GIT_SSH_COMMAND="ssh -i `pwd`/open_bus_pipelines_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\
git clone [email protected]:hasadna/open-bus-pipelines.git &&\
cd open-bus-pipelines &&\
( cd $OPEN_BUS_SIRI_ETL_ROOTDIR && bin/get_siri_etl_requirements.py "${GITHUB_SHA}" ) > requirements-siri-etl.txt &&\
git add requirements-siri-etl.txt &&\
git commit -m "automatic update of siri etl requirements" &&\
git push origin main
fi
fi