From 20ed9e07db7bd2ed0bf89f997885a24d4922591c Mon Sep 17 00:00:00 2001 From: Hidde Wieringa <hidde@hiddewieringa.nl> Date: Sun, 21 Apr 2024 20:00:19 +0200 Subject: [PATCH] Trigger from Github Actions to CircleCI for nightly update --- .circleci/config.yml | 61 +--------------------------- .circleci/nightly-update.yml | 53 ++++++++++++++++++++++++ .github/workflows/nightly-update.yml | 21 ++++++++++ 3 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 .circleci/nightly-update.yml create mode 100644 .github/workflows/nightly-update.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 19848857..f4aa351b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,61 +1,4 @@ version: 2.1 -executors: - default: - machine: - image: ubuntu-2204:current - resource_class: medium - -jobs: - import-data: - executor: default - steps: - - checkout - - run: wget -qO- 'https://getfly.fly.dev/linux-x86-64/flyctl.tgz' | tar xz - - run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_USERNAME" --password-stdin - - run: docker compose build db - - run: docker compose build import - - run: docker compose build martin-cp - - run: docker compose up --wait db - - run: curl --location --progress-bar https://download.geofabrik.de/europe-latest.osm.pbf --output data/data.osm.pbf - - run: - no_output_timeout: 1h - environment: - OSM2PGSQL_DATAFILE: data.osm.pbf - OSM2PGSQL_CACHE: '7000' - OSM2PGSQL_NUMPROC: '2' - command: docker compose up import - - run: | - docker compose stop db - DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')" - DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')" - - # Persist and squash data in new image - docker cp "$DB_CONTAINER_ID:/var/lib/postgresql/postgres-data" db/postgres-data - echo 'COPY postgres-data /var/lib/postgresql/postgres-data' >> db/Dockerfile - - docker compose build db - docker compose push db - - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/hiddewie/OpenRailwayMap-vector/actions/workflows/deploy.yml/dispatches \ - -d "$(jq -c -n --arg branch "$CIRCLE_BRANCH" '{ref: $branch}')" - -workflows: - auto-deployment: - triggers: - - schedule: - # Run daily at 3:47 UTC - cron: "47 3 * * *" - filters: - branches: - only: - - master - jobs: - - import-data: - context: - - github +jobs: {} +workflows: {} diff --git a/.circleci/nightly-update.yml b/.circleci/nightly-update.yml new file mode 100644 index 00000000..6e63f528 --- /dev/null +++ b/.circleci/nightly-update.yml @@ -0,0 +1,53 @@ +version: 2.1 + +executors: + default: + machine: + image: ubuntu-2204:current + resource_class: medium + +jobs: + import-data: + executor: default + steps: + - checkout + - run: wget -qO- 'https://getfly.fly.dev/linux-x86-64/flyctl.tgz' | tar xz + - run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_USERNAME" --password-stdin + - run: docker compose build db + - run: docker compose build import + - run: docker compose build martin-cp + - run: docker compose up --wait db + - run: curl --location --progress-bar https://download.geofabrik.de/europe-latest.osm.pbf --output data/data.osm.pbf + - run: + no_output_timeout: 1h + environment: + OSM2PGSQL_DATAFILE: data.osm.pbf + OSM2PGSQL_CACHE: '7000' + OSM2PGSQL_NUMPROC: '2' + command: docker compose up import + - run: | + docker compose stop db + DB_CONTAINER_ID="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .ID')" + DB_IMAGE="$(docker compose ps --all --format json | jq -r 'select(.Service == "db") | .Image')" + + # Persist and squash data in new image + docker cp "$DB_CONTAINER_ID:/var/lib/postgresql/postgres-data" db/postgres-data + echo 'COPY postgres-data /var/lib/postgresql/postgres-data' >> db/Dockerfile + + docker compose build db + docker compose push db + - run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/hiddewie/OpenRailwayMap-vector/actions/workflows/deploy.yml/dispatches \ + -d "$(jq -c -n --arg branch "$CIRCLE_BRANCH" '{ref: $branch}')" + +workflows: + auto-deployment: + jobs: + - import-data: + context: + - github diff --git a/.github/workflows/nightly-update.yml b/.github/workflows/nightly-update.yml new file mode 100644 index 00000000..4cd60a20 --- /dev/null +++ b/.github/workflows/nightly-update.yml @@ -0,0 +1,21 @@ +name: Nightly update + +on: + workflow_dispatch: ~ + schedule: + # Run daily at 3:47 UTC + - cron: '47 3 * * *' + +jobs: + trigger-circle-ci: + name: Trigger CircleCI + runs-on: ubuntu-latest + + steps: + - run: | + curl \ + -X POST \ + -H "content-type: application/json" \ + "https://internal.circleci.com/private/soc/e/4137caec-ceea-4722-9803-8ab90a8d2355?secret=$CIRCLECI_WEBHOOK_SECRET" + env: + CIRCLECI_WEBHOOK_SECRET: ${{ secrets.CIRCLECI_WEBHOOK_SECRET }}