Skip to content

Commit

Permalink
Trigger from Github Actions to CircleCI for nightly update
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Apr 21, 2024
1 parent 853339c commit 20ed9e0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 59 deletions.
61 changes: 2 additions & 59 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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: {}
53 changes: 53 additions & 0 deletions .circleci/nightly-update.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .github/workflows/nightly-update.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 20ed9e0

Please sign in to comment.