GitLab, Gitea & Forgejo

Potions can build your app from GitLab (including self-managed GitLab), Gitea, Forgejo, Codeberg, or any other git server, not just GitHub. There's nothing to install: you paste the repository URL, and Potions clones it with git using a read-only deploy key it creates for each app.

What you need

  • A repository Potions' build servers can reach. Builds clone your code on a Potions build server, so your git host must be reachable from the internet. A host behind a firewall works if you allow the addresses at potions.io/ips.
  • The repository's SSH URL, like git@gitea.example.com:team/shop.git or ssh://git@gitea.example.com:2222/team/shop.git. For a public repository, its https:// URL works too, with no key at all.
  • Permission to add a deploy key to the repository (repository admin or maintainer).

Adding an app

  1. On your server's Apps page, click Add app.
  2. Under Git host, pick GitLab, Gitea, Forgejo or Codeberg, or Another git host.
  3. Paste the Repository URL. Potions names the app after the repository; change the name and branch if you like.
  4. Pick your Elixir and Erlang versions and a database, then click Create app.

Adding the deploy key

The app's Overview shows a Connect your repository card with the app's deploy key. Click Copy, then add it to the repository:

  • GitLab: the project's Settings, then Repository, then Deploy keys. Paste the key and leave Grant write permissions off.
  • Gitea: the repository's Settings, then Deploy Keys, then Add Deploy Key. Leave Enable Write Access off.
  • Forgejo and Codeberg: the repository's Settings, then Deploy keys. Leave write access off.
  • Anything else: add it as a read-only deploy key, or to an account that can read the repository.

Then click Test connection. Potions connects from a build server, the same way a build does, and lists the repository's branches. Once it works, the card goes away and you can deploy.

Each app has its own key, so a key only ever opens one repository. You can generate a new one from the app's Settings at any time; builds fail until the new key is added to the repository.

Deploying on push

Potions doesn't call your git host's API, so instead of registering a webhook for you it shows you the one to add. Turn on Auto-deploy on push in the app's Settings, then:

  • Gitea and Forgejo: the repository's Settings, then Webhooks, then Add webhook and choose Gitea (or Forgejo). Paste the Target URL and Secret Potions shows, keep the method POST and the content type application/json, and trigger on push events. Gitea signs every delivery with the secret.
  • GitLab: the project's Settings, then Webhooks, then Add new webhook. Paste the URL and Secret token, and tick Push events.
  • Another git host: Potions shows a deploy hook URL with the secret built in. Have your git host, or your CI, send a POST to it on every push. Keep it private.

Pushes to other branches are ignored, and deleting a branch never starts a deploy.

Deploying from CI

The deploy hook also works from a CI job, which lets you deploy only once tests pass. Save the deploy hook URL as a secret, then add a step at the end of your pipeline:

curl -fsS -X POST "$POTIONS_DEPLOY_HOOK&sha=$CI_COMMIT_SHA"

sha is the full commit to deploy: $CI_COMMIT_SHA on GitLab CI, $GITHUB_SHA on Gitea and Forgejo Actions. Leave it off to deploy the latest commit on the app's branch. The hook only deploys while auto-deploy is on.

Host keys

The first time a build server connects to your git host over SSH, Potions saves the host's SSH key and from then on refuses a server that presents a different one. The app's Settings show the saved key's fingerprint. If you rebuild your git server and its key changes on purpose, click Forget the saved host key, then Test connection to save the new one.

Things to Know

  • There's no repository list. Potions doesn't read your account on these hosts, so you paste the URL instead of picking it.
  • HTTPS URLs are for public repositories. Potions sends no username, password or token over HTTPS. For a private repository, use the SSH URL and the deploy key.
  • Builds always run on a build server. These apps never use the Fly.io build fallback, which has no fixed address to allow through a firewall.
  • Manual deploys show the commit, not its message. Potions finds the latest commit with git, which doesn't include the message or author. Deploys started by a webhook show both.
  • The CLI and the agent tools create GitHub apps only. Apps on other hosts are added from the dashboard; once added, you can deploy them from the API, the CLI and your agent like any other app.