Appearance
CI/CD with GitHub Actions
Services connected to a GitHub repository already deploy on every push. Use GitHub Actions when you want to deploy only after your tests pass, deploy several services in order, or deploy images you build yourself.
All examples use a team API token stored as the repository secret FJORDRUN_TOKEN (Settings → Secrets and variables → Actions in GitHub).
Find the IDs
Link your directory with the CLI and print the IDs:
bash
fjordrun link
fjordrun status --jsonOr read FJORDRUN_SERVICE_ID from the service's variables. Store the service ID (and the environment ID, if not production) as repository variables.
Redeploy after tests, with the CLI
yaml
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 22, cache: npm }
- run: npm ci
- run: npm test
deploy:
needs: test
runs-on: ubuntu-latest
env:
FJORDRUN_TOKEN: ${{ secrets.FJORDRUN_TOKEN }}
steps:
- name: Install the Fjordrun CLI
run: curl -fsSL https://fjordrun.com/install.sh | sh
- name: Deploy
run: fjordrun deploy --project shop --service web --environment production --wait--wait streams the build and fails the job if the deployment fails.
To avoid deploying twice (once on push, once from CI), set the service's watch paths to something that never changes, or connect the service to a branch that only CI updates.
Redeploy after tests, with curl
yaml
- name: Deploy
run: |
curl -fsS -X POST \
"https://api.fjordrun.com/api/v1/services/${{ vars.FJORDRUN_SERVICE_ID }}/deploy" \
-H "Authorization: Bearer ${{ secrets.FJORDRUN_TOKEN }}"Add ?environment_id=<id> for an environment other than production. The response is the new deployment; follow it with GET /api/v1/deployments/{id} until its status is success or failed.
Build the image in CI, deploy it on Fjordrun
For full control of the build (or builds that need more memory), build and push the image yourself and deploy it to a service whose source is a Docker image:
yaml
deploy:
needs: test
runs-on: ubuntu-latest
permissions: { contents: read, packages: write }
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
- name: Point the service at the new image
run: |
curl -fsS -X PATCH \
"https://api.fjordrun.com/api/v1/services/${{ vars.FJORDRUN_SERVICE_ID }}/config" \
-H "Authorization: Bearer ${{ secrets.FJORDRUN_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"source": {"type": "image", "image": "ghcr.io/${{ github.repository }}:${{ github.sha }}"}}'Changing the image of a running service deploys it. The image must be pullable by Fjordrun; make the GHCR package public, or use a public registry.
arm64
During the beta, Fjordrun's servers are arm64 (Ampere) machines. Images you build yourself must include linux/arm64: add platforms: linux/amd64,linux/arm64 to docker/build-push-action, with docker/setup-qemu-action and docker/setup-buildx-action before it. Images built by Fjordrun from your repository are built for the right architecture automatically.