DEV Community

Alan Schio
Alan Schio

Posted on

Deploy to Fly.io with bitbucket-pipelines

It is easy to find integrations for Github or GitLab, but i spent a couple of minutes trying to make it work, so why no sharing?

Create Fly Token

First go to your Fly.io App and create a Deploy Token (https://fly.io/apps/your-app/tokens)

Fly.io Create Deploy Token dialog

Let the Expiration if you want it to never expires

Token Generated

Add a Repository Variable

Now go to your bitbucket repository settings, under Pipeline side menu, at Repository Variables (https://bitbucket.org/YOURORG/YOURPROJECT/YOURREPO/pipelines/repository-variables).
And create a new variable with the name FLY_API_TOKEN.

Bitbucket add variable

Create the pipeline file

Now create your bitbucket-pipelines.yml file and use the golang image so you can install the flyctl and deploy your app.

image: golang:1.15
pipelines:
  default:
    - step:
        name: Deploy to Fly.io
        deployment: production
        script:
          - apt-get update -qq && apt-get install -y curl
          - curl -L https://fly.io/install.sh | sh
          - export FLYCTL_INSTALL="/root/.fly"
          - export PATH="$FLYCTL_INSTALL/bin:$PATH"
          - flyctl deploy

Enter fullscreen mode Exit fullscreen mode

Top comments (0)