Skip to content

Commit 8a680b7

Browse files
author
Matt Pryor
authored
Correct condition in sample GitLab CI config (azimuth-cloud#141)
1 parent c75f7e8 commit 8a680b7

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

.gitlab-ci.yml.sample

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,10 @@ deploy_aio:
100100
when: never
101101
# Allow deployments to be manually triggered even when there are no changed files
102102
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
103-
# Run when there is a push to a branch with a merge request that changes one of the relevant files
104-
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event"
105-
changes:
106-
# Files that affect the aio environment
107-
- env
108-
- env.secret
109-
- requirements.yml
110-
- environments/base/**/*
111-
- environments/singlenode/**/*
112-
- environments/site/**/*
113-
- environments/aio/**/*
103+
# Run when there is a push to a branch with a merge request to main
104+
- if: >-
105+
$CI_PIPELINE_SOURCE == "merge_request_event" &&
106+
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
114107
environment:
115108
name: aio/$CI_COMMIT_REF_SLUG
116109
on_stop: stop_aio
@@ -130,22 +123,12 @@ deploy_aio:
130123
test_aio:
131124
stage: aio_test
132125
rules:
133-
# Do not run for commits to main
134126
- if: $CI_COMMIT_BRANCH == "main"
135127
when: never
136-
# Allow deployments to be manually triggered even when there are no changed files
137128
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
138-
# Run when there is a push to a branch with a merge request that changes one of the relevant files
139-
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event"
140-
changes:
141-
# Files that affect the aio environment
142-
- env
143-
- env.secret
144-
- requirements.yml
145-
- environments/base/**/*
146-
- environments/singlenode/**/*
147-
- environments/site/**/*
148-
- environments/aio/**/*
129+
- if: >-
130+
$CI_PIPELINE_SOURCE == "merge_request_event" &&
131+
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
149132
environment:
150133
name: aio/$CI_COMMIT_REF_SLUG
151134
variables:
@@ -174,16 +157,9 @@ stop_aio:
174157
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "web"
175158
when: manual
176159
allow_failure: true
177-
- if: $CI_COMMIT_BRANCH && $CI_PIPELINE_SOURCE == "merge_request_event"
178-
changes:
179-
# Files that affect the aio environment
180-
- env
181-
- env.secret
182-
- requirements.yml
183-
- environments/base/**/*
184-
- environments/singlenode/**/*
185-
- environments/site/**/*
186-
- environments/aio/**/*
160+
- if: >-
161+
$CI_PIPELINE_SOURCE == "merge_request_event" &&
162+
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
187163
when: manual
188164
allow_failure: true
189165
environment:

0 commit comments

Comments
 (0)