|
| 1 | +# Runway GitLab CI Template |
| 2 | + |
| 3 | +This template provides complete Runway CLI setup functionality for GitLab CI/CD pipelines, equivalent to the GitHub Action version. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +1. Include the template in your `.gitlab-ci.yml`: |
| 8 | + |
| 9 | +```yaml |
| 10 | +include: |
| 11 | + - remote: 'https://raw.githubusercontent.com/your-org/setup-runway/main/gitlab/runway-complete.yml' |
| 12 | + |
| 13 | +deploy: |
| 14 | + extends: .runway-setup |
| 15 | + variables: |
| 16 | + RUNWAY_USERNAME: $RUNWAY_USER |
| 17 | + RUNWAY_PASSWORD: $RUNWAY_PASS |
| 18 | + script: |
| 19 | + - runway app deploy |
| 20 | +``` |
| 21 | +
|
| 22 | +2. Set required CI/CD variables in your GitLab project: |
| 23 | + - `RUNWAY_USER`: Your runway username |
| 24 | + - `RUNWAY_PASS`: Your runway password |
| 25 | + |
| 26 | +## Configuration Variables |
| 27 | + |
| 28 | +### Required Variables |
| 29 | + |
| 30 | +| Variable | Description | |
| 31 | +|----------|-------------| |
| 32 | +| `RUNWAY_USERNAME` | Runway account username | |
| 33 | +| `RUNWAY_PASSWORD` | Runway account password | |
| 34 | + |
| 35 | +### Optional Variables |
| 36 | + |
| 37 | +| Variable | Description | Default | |
| 38 | +|----------|-------------|---------| |
| 39 | +| `RUNWAY_APPLICATION` | Runway application name | `""` | |
| 40 | +| `RUNWAY_VERSION` | Runway CLI version | `"latest"` | |
| 41 | +| `RUNWAY_LOG_LEVEL` | Log level: debug, info, warn, error | `"error"` | |
| 42 | +| `RUNWAY_CONTROLLER_URL` | Custom controller URL | `""` | |
| 43 | +| `RUNWAY_ADD_KEY` | Import SSH key: "true" or "false" | `"false"` | |
| 44 | +| `RUNWAY_SETUP_SSH` | Setup SSH agent: "true" or "false" | `"false"` | |
| 45 | +| `RUNWAY_PRIVATE_KEY` | SSH private key content | `""` | |
| 46 | +| `RUNWAY_PUBLIC_KEY` | SSH public key content | `""` | |
| 47 | +| `RUNWAY_PUBLIC_KEY_LOCATION` | SSH public key file path | `"~/.ssh/id_rsa.pub"` | |
| 48 | +| `RUNWAY_PRIVATE_KEY_LOCATION` | SSH private key file path | `"~/.ssh/id_rsa"` | |
| 49 | + |
| 50 | +## Usage Examples |
| 51 | + |
| 52 | +Please note that any deployment requires your SSH key. But you can set them up yourself if you don't want us to paste them into place and set permissions. |
| 53 | + |
| 54 | +### Basic Example |
| 55 | + |
| 56 | +```yaml |
| 57 | +include: |
| 58 | + - remote: 'https://raw.githubusercontent.com/your-org/setup-runway/main/gitlab/runway-complete.yml' |
| 59 | +
|
| 60 | +deploy: |
| 61 | + extends: .runway-setup |
| 62 | + variables: |
| 63 | + RUNWAY_USERNAME: $RUNWAY_USER |
| 64 | + RUNWAY_PASSWORD: $RUNWAY_PASS |
| 65 | + script: |
| 66 | + - runway app ls |
| 67 | + rules: |
| 68 | + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH |
| 69 | +``` |
| 70 | + |
| 71 | +### Deployment (including SSH Setup) |
| 72 | + |
| 73 | +```yaml |
| 74 | +include: |
| 75 | + - remote: 'https://raw.githubusercontent.com/your-org/setup-runway/main/gitlab/runway-complete.yml' |
| 76 | +
|
| 77 | +deploy: |
| 78 | + extends: .runway-setup |
| 79 | + variables: |
| 80 | + RUNWAY_USERNAME: $RUNWAY_USER |
| 81 | + RUNWAY_PASSWORD: $RUNWAY_PASS |
| 82 | + RUNWAY_APPLICATION: "my-app" |
| 83 | + RUNWAY_SETUP_SSH: "true" |
| 84 | + RUNWAY_ADD_KEY: "true" |
| 85 | + RUNWAY_PRIVATE_KEY: $SSH_PRIVATE_KEY |
| 86 | + RUNWAY_PUBLIC_KEY: $SSH_PUBLIC_KEY |
| 87 | + script: |
| 88 | + - runway app deploy -a $RUNWAY_APPLICATION |
| 89 | +``` |
| 90 | + |
| 91 | +### Multi-Stage Pipeline |
| 92 | + |
| 93 | +```yaml |
| 94 | +include: |
| 95 | + - remote: 'https://raw.githubusercontent.com/your-org/setup-runway/main/gitlab/runway-complete.yml' |
| 96 | +
|
| 97 | +stages: |
| 98 | + - deploy-staging |
| 99 | + - deploy-production |
| 100 | +
|
| 101 | +deploy-staging: |
| 102 | + stage: deploy-staging |
| 103 | + extends: .runway-setup |
| 104 | + variables: |
| 105 | + RUNWAY_USERNAME: $RUNWAY_USER |
| 106 | + RUNWAY_PASSWORD: $RUNWAY_PASS |
| 107 | + RUNWAY_APPLICATION: "my-app-staging" |
| 108 | + script: |
| 109 | + - runway app deploy -a my-app-staging |
| 110 | + rules: |
| 111 | + - if: $CI_COMMIT_BRANCH == "develop" |
| 112 | +
|
| 113 | +deploy-production: |
| 114 | + stage: deploy-production |
| 115 | + extends: .runway-setup |
| 116 | + variables: |
| 117 | + RUNWAY_USERNAME: $RUNWAY_USER |
| 118 | + RUNWAY_PASSWORD: $RUNWAY_PASS |
| 119 | + RUNWAY_APPLICATION: "my-app-prod" |
| 120 | + script: |
| 121 | + - runway app deploy -a my-app-prod |
| 122 | + rules: |
| 123 | + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH |
| 124 | + when: manual |
| 125 | +``` |
| 126 | + |
| 127 | +## Setting Up CI/CD Variables |
| 128 | + |
| 129 | +1. Go to your GitLab project |
| 130 | +2. Navigate to Settings → CI/CD → Variables |
| 131 | +3. Add the required variables: |
| 132 | + - `RUNWAY_USER` (Type: Variable, Masked: Yes) |
| 133 | + - `RUNWAY_PASS` (Type: Variable, Masked: Yes) |
| 134 | + - `SSH_PRIVATE_KEY` (Type: File, Masked: Yes) |
| 135 | + - `SSH_PUBLIC_KEY` (Type: Variable) |
| 136 | + |
| 137 | +## Features |
| 138 | + |
| 139 | +This template provides the same functionality as the GitHub Action: |
| 140 | + |
| 141 | +✅ **CLI Installation**: Downloads and installs runway CLI |
| 142 | +✅ **Authentication**: Logs into runway with credentials |
| 143 | +✅ **Architecture Detection**: Supports x86_64/amd64 and ARM64 runners |
| 144 | +✅ **SSH Key Management**: Optionally sets up SSH keys |
| 145 | +✅ **Application Management**: Creates or connects to runway applications |
| 146 | +✅ **SSH Agent Setup**: Configures SSH agent for deployments |
| 147 | +✅ **Custom Controllers**: Support for enterprise/testing environments |
| 148 | +✅ **Version Control**: Specify exact runway CLI versions |
| 149 | + |
| 150 | +## Architecture Support |
| 151 | + |
| 152 | +The template automatically detects runner architecture: |
| 153 | + |
| 154 | +- `x86_64` → `amd64` (Intel/AMD 64-bit) |
| 155 | +- `aarch64` → `arm64` (Linux ARM64) |
| 156 | +- `arm64` → `arm64` (macOS ARM64) |
| 157 | + |
| 158 | +## Troubleshooting |
| 159 | + |
| 160 | +### Binary Installation Issues |
| 161 | + |
| 162 | +If the runway binary can't be moved to `/usr/local/bin`, the template will try `~/bin` or place it in the current directory. Ensure your GitLab runner has appropriate permissions or add the current directory to PATH: |
| 163 | + |
| 164 | +```yaml |
| 165 | +script: |
| 166 | + - export PATH="$PWD:$PATH" |
| 167 | + - runway app deploy |
| 168 | +``` |
| 169 | + |
| 170 | +### SSH Issues |
| 171 | + |
| 172 | +Ensure your SSH keys are properly formatted in GitLab CI/CD variables: |
| 173 | + |
| 174 | + - Private key should include `-----BEGIN` and `-----END` lines |
| 175 | + - Public key should be a single line |
| 176 | + |
| 177 | +### Permission Errors |
| 178 | + |
| 179 | +The template sets proper permissions (0600) on SSH key files automatically. |
| 180 | + |
| 181 | +## Contributing |
| 182 | + |
| 183 | +This template mirrors the functionality of the GitHub Action in `action.yml`. When updating, ensure both remain in sync. |
0 commit comments