v2.31.0-dev2 4b72742

gitlab-ci.md RawHistoryFolder

GitLab CI/CD Deployment

Automated deployment with GitLab CI/CD using Gordon's push command.

Prerequisites

  1. Gordon server running with registry authentication enabled
  2. Generated deployment token
  3. GitLab CI/CD variables configured

Quick Setup

1. Generate Deployment Token

On your Gordon server:

gordon auth token generate \
  --subject gitlab-ci \
  --scopes "push,pull,admin:routes:read,admin:config:write" \
  --expiry 0

2. Add CI/CD Variables

In your project: Settings > CI/CD > Variables

Variable Value Protected Masked
GORDON_TOKEN The generated token Yes Yes
GORDON_REMOTE https://gordon.example.com Yes No

3. Create Pipeline

Create .gitlab-ci.yml:

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
    - chmod +x /usr/local/bin/gordon
  script:
    - gordon push --build
        --remote "$GORDON_REMOTE"
        --token "$GORDON_TOKEN"
        --no-confirm
  only:
    - tags

Gordon auto-detects the version from $CI_COMMIT_TAG.

Pipeline Examples

Deploy on Tag Push

stages:
  - deploy

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
    - chmod +x /usr/local/bin/gordon
  script:
    - gordon push --build
        --remote "$GORDON_REMOTE"
        --token "$GORDON_TOKEN"
        --no-confirm
  rules:
    - if: $CI_COMMIT_TAG

Continuous Deployment

Deploy on every push to main:

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
    - chmod +x /usr/local/bin/gordon
  script:
    - gordon push --build
        --remote "$GORDON_REMOTE"
        --token "$GORDON_TOKEN"
        --no-confirm
  rules:
    - if: $CI_COMMIT_BRANCH == "main"

Manual Deployment

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
    - chmod +x /usr/local/bin/gordon
  script:
    - gordon push --build
        --remote "$GORDON_REMOTE"
        --token "$GORDON_TOKEN"
        --no-confirm
  when: manual

With Build Arguments

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
    - chmod +x /usr/local/bin/gordon
  script:
    - gordon push --build
        --remote "$GORDON_REMOTE"
        --token "$GORDON_TOKEN"
        --build-arg NODE_ENV=production
        --build-arg API_URL=https://api.example.com
        --no-confirm
  rules:
    - if: $CI_COMMIT_TAG

Alternative: Docker-based Pipeline

For environments where installing the Gordon binary is not desired:

deploy:
  stage: deploy
  image: docker:24
  services:
    - docker:24-dind
  script:
    - echo "$GORDON_TOKEN" | docker login "$GORDON_REGISTRY" -u "$GORDON_USERNAME" --password-stdin
    - docker build -t "$GORDON_REGISTRY/myapp:$CI_COMMIT_TAG" .
    - docker push "$GORDON_REGISTRY/myapp:$CI_COMMIT_TAG"
  rules:
    - if: $CI_COMMIT_TAG

This requires additional CI/CD variables: GORDON_REGISTRY and GORDON_USERNAME. Gordon auto-deploys when it receives the image.

Version Detection

Gordon automatically detects the version tag from GitLab CI environment variables:

Variable Example Result
$CI_COMMIT_TAG v1.2.0 Tag v1.2.0
No tag - Falls back to git describe or latest

Troubleshooting

Authentication Failed

Error: failed to verify token

Verify GORDON_TOKEN is correctly set and the token has not been revoked.

Docker-in-Docker Issues

If using docker:dind, ensure the service is properly configured:

services:
  - docker:24-dind
variables:
  DOCKER_TLS_CERTDIR: "/certs"

Build Context

GitLab CI clones your repository automatically. The build context defaults to the repository root.

source
1# GitLab CI/CD Deployment
2
3Automated deployment with GitLab CI/CD using Gordon's push command.
4
5## Prerequisites
6
71. Gordon server running with registry authentication enabled
82. Generated deployment token
93. GitLab CI/CD variables configured
10
11## Quick Setup
12
13### 1. Generate Deployment Token
14
15On your Gordon server:
16
17```bash
18gordon auth token generate \
19  --subject gitlab-ci \
20  --scopes "push,pull,admin:routes:read,admin:config:write" \
21  --expiry 0
22```
23
24### 2. Add CI/CD Variables
25
26In your project: Settings > CI/CD > Variables
27
28| Variable | Value | Protected | Masked |
29|----------|-------|-----------|--------|
30| `GORDON_TOKEN` | The generated token | Yes | Yes |
31| `GORDON_REMOTE` | `https://gordon.example.com` | Yes | No |
32
33### 3. Create Pipeline
34
35Create `.gitlab-ci.yml`:
36
37```yaml
38deploy:
39  stage: deploy
40  image: docker:24
41  services:
42    - docker:24-dind
43  before_script:
44    - apk add --no-cache curl
45    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
46    - chmod +x /usr/local/bin/gordon
47  script:
48    - gordon push --build
49        --remote "$GORDON_REMOTE"
50        --token "$GORDON_TOKEN"
51        --no-confirm
52  only:
53    - tags
54```
55
56Gordon auto-detects the version from `$CI_COMMIT_TAG`.
57
58## Pipeline Examples
59
60### Deploy on Tag Push
61
62```yaml
63stages:
64  - deploy
65
66deploy:
67  stage: deploy
68  image: docker:24
69  services:
70    - docker:24-dind
71  before_script:
72    - apk add --no-cache curl
73    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
74    - chmod +x /usr/local/bin/gordon
75  script:
76    - gordon push --build
77        --remote "$GORDON_REMOTE"
78        --token "$GORDON_TOKEN"
79        --no-confirm
80  rules:
81    - if: $CI_COMMIT_TAG
82```
83
84### Continuous Deployment
85
86Deploy on every push to main:
87
88```yaml
89deploy:
90  stage: deploy
91  image: docker:24
92  services:
93    - docker:24-dind
94  before_script:
95    - apk add --no-cache curl
96    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
97    - chmod +x /usr/local/bin/gordon
98  script:
99    - gordon push --build
100        --remote "$GORDON_REMOTE"
101        --token "$GORDON_TOKEN"
102        --no-confirm
103  rules:
104    - if: $CI_COMMIT_BRANCH == "main"
105```
106
107### Manual Deployment
108
109```yaml
110deploy:
111  stage: deploy
112  image: docker:24
113  services:
114    - docker:24-dind
115  before_script:
116    - apk add --no-cache curl
117    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
118    - chmod +x /usr/local/bin/gordon
119  script:
120    - gordon push --build
121        --remote "$GORDON_REMOTE"
122        --token "$GORDON_TOKEN"
123        --no-confirm
124  when: manual
125```
126
127### With Build Arguments
128
129```yaml
130deploy:
131  stage: deploy
132  image: docker:24
133  services:
134    - docker:24-dind
135  before_script:
136    - apk add --no-cache curl
137    - curl -fsSL https://github.com/bnema/gordon/releases/latest/download/gordon_linux_amd64 -o /usr/local/bin/gordon
138    - chmod +x /usr/local/bin/gordon
139  script:
140    - gordon push --build
141        --remote "$GORDON_REMOTE"
142        --token "$GORDON_TOKEN"
143        --build-arg NODE_ENV=production
144        --build-arg API_URL=https://api.example.com
145        --no-confirm
146  rules:
147    - if: $CI_COMMIT_TAG
148```
149
150## Alternative: Docker-based Pipeline
151
152For environments where installing the Gordon binary is not desired:
153
154```yaml
155deploy:
156  stage: deploy
157  image: docker:24
158  services:
159    - docker:24-dind
160  script:
161    - echo "$GORDON_TOKEN" | docker login "$GORDON_REGISTRY" -u "$GORDON_USERNAME" --password-stdin
162    - docker build -t "$GORDON_REGISTRY/myapp:$CI_COMMIT_TAG" .
163    - docker push "$GORDON_REGISTRY/myapp:$CI_COMMIT_TAG"
164  rules:
165    - if: $CI_COMMIT_TAG
166```
167
168This requires additional CI/CD variables: `GORDON_REGISTRY` and `GORDON_USERNAME`.
169Gordon auto-deploys when it receives the image.
170
171## Version Detection
172
173Gordon automatically detects the version tag from GitLab CI environment variables:
174
175| Variable | Example | Result |
176|----------|---------|--------|
177| `$CI_COMMIT_TAG` | `v1.2.0` | Tag `v1.2.0` |
178| No tag | - | Falls back to `git describe` or `latest` |
179
180## Troubleshooting
181
182### Authentication Failed
183
184```text
185Error: failed to verify token
186```
187
188Verify `GORDON_TOKEN` is correctly set and the token has not been revoked.
189
190### Docker-in-Docker Issues
191
192If using `docker:dind`, ensure the service is properly configured:
193
194```yaml
195services:
196  - docker:24-dind
197variables:
198  DOCKER_TLS_CERTDIR: "/certs"
199```
200
201### Build Context
202
203GitLab CI clones your repository automatically. The build context defaults to the repository root.
204
205## Related
206
207- [GitHub Actions](./github-actions.md)
208- [Generic CI](./generic-ci.md)
209- [Deployment Overview](./index.md)
210- [Authentication](../config/auth.md)
211- [Push Command](../cli/push.md)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close