Deploy from your own CI
Run your tests in GitHub Actions, GitLab CI, or any pipeline, and deploy to Olimpia only when they pass.
Automatic deploys with GitHub deploy every push with no extra steps. If you want your pipeline to decide when to deploy (for example, after running your tests), use an app with uploaded code and call the API from your CI.
What you need
- An app created with
source: "upload". See Upload your folder. - A personal token, stored as a CI secret (
OLIMPIA_TOKEN). - The app’s
id, stored as a CI variable (OLIMPIA_APP_ID).
GitHub Actions
name: Deploy a Olimpia
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Subir y desplegar
env:
OLIMPIA_TOKEN: ${{ secrets.OLIMPIA_TOKEN }}
APP_ID: ${{ vars.OLIMPIA_APP_ID }}
run: |
api=https://api.olimpia.dev
auth="Authorization: Bearer $OLIMPIA_TOKEN"
upload=$(curl -fsS -X POST -H "$auth" "$api/apps/$APP_ID/source")
git archive --format=tar.gz --prefix=src/ -o /tmp/src.tar.gz HEAD
curl -fsS -X PUT -T /tmp/src.tar.gz "$(echo "$upload" | jq -r .upload_url)"
curl -fsS -X POST -H "$auth" -H 'content-type: application/json' \
-d "{\"source\": \"$(echo "$upload" | jq -r .key)\", \"message\": \"$GITHUB_SHA\"}" \
"$api/apps/$APP_ID/deployments" > /dev/null
GitLab CI
deploy:
stage: deploy
image: alpine:3.22
only: [main]
script:
- apk add --no-cache curl jq git
- api=https://api.olimpia.dev
- auth="Authorization: Bearer $OLIMPIA_TOKEN"
- upload=$(curl -fsS -X POST -H "$auth" "$api/apps/$OLIMPIA_APP_ID/source")
- git archive --format=tar.gz --prefix=src/ -o /tmp/src.tar.gz HEAD
- curl -fsS -X PUT -T /tmp/src.tar.gz "$(echo "$upload" | jq -r .upload_url)"
- >
curl -fsS -X POST -H "$auth" -H 'content-type: application/json'
-d "{\"source\": \"$(echo "$upload" | jq -r .key)\", \"message\": \"$CI_COMMIT_SHA\"}"
"$api/apps/$OLIMPIA_APP_ID/deployments"
Wait for the result
The deployments POST returns right away. To make the pipeline fail when the deploy fails, poll the latest deploy until it finishes:
until status=$(curl -fsS -H "$auth" "$api/apps/$APP_ID/deployments" | jq -r '.[0].status'); \
[ "$status" = active ] || [ "$status" = failed ] || [ "$status" = canceled ]; do sleep 10; done
[ "$status" = active ]