Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Frontend
Commits
4ded1895
Commit
4ded1895
authored
5 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Run Surge builds on branches to automatically remove deployments
parent
c1f78ee3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+46
-30
46 additions, 30 deletions
.gitlab-ci.yml
with
46 additions
and
30 deletions
.gitlab-ci.yml
+
46
−
30
View file @
4ded1895
...
...
@@ -4,29 +4,31 @@ stages:
-
build
-
deploy
# Prevent detached merge request pipelines
# https://docs.gitlab.com/ee/ci/merge_request_pipelines/
# Those do not run the environment on_stop jobs when MRs are closed/merged
# or when branches get deleted, unlike branch pipelines.
workflow
:
rules
:
-
if
:
'
$CI_MERGE_REQUEST_ID'
when
:
never
-
when
:
always
before_script
:
-
npm ci
.test
:
stage
:
test
only
:
# Default "only" + merge_requests
-
branches
-
tags
-
merge_requests
frontend-test
:
extends
:
.
test
stage
:
test
script
:
-
npm run test
frontend-lint
:
extends
:
.
test
stage
:
test
script
:
-
npm run lint
frontend-audit
:
extends
:
.
test
stage
:
test
script
:
-
npm audit --parseable
allow_failure
:
true
...
...
@@ -45,11 +47,14 @@ frontend-audit:
script
:
-
npm run production
frontend-build-
mr
:
frontend-build-
surge
:
extends
:
.build
only
:
-
merge_requests
# Only deploy branches on surge
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
&&
$CI_COMMIT_BRANCH
!=
"master"'
when
:
on_success
-
when
:
never
variables
:
# On merge requests we build using preprod to be able
...
...
@@ -60,46 +65,57 @@ frontend-build-mr:
frontend-build
:
extends
:
.build
except
:
-
merge_requests
# Build only for master and tags
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
&&
$CI_COMMIT_BRANCH
!=
"master"'
when
:
never
-
when
:
on_success
variables
:
# On default branches we build using a relative API Url
API_BASE_URL
:
/api/v1
deploy-
surge
:
.
surge
:
stage
:
deploy
# Only deploy merge requests on surge
only
:
-
merge_requests
environment
:
name
:
${CI_COMMIT_REF_SLUG}
url
:
https://${CI_COMMIT_REF_SLUG}-teklia.surge.sh
on_stop
:
stop-surge
before_script
:
-
npm install -g surge
deploy-surge
:
extends
:
.surge
# Only deploy branches on surge
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
&&
$CI_COMMIT_BRANCH
!=
"master"'
when
:
on_success
-
when
:
never
environment
:
url
:
https://${CI_COMMIT_REF_SLUG}-teklia.surge.sh
on_stop
:
stop-surge
script
:
-
surge dist ${CI_ENVIRONMENT_URL}
stop-surge
:
stage
:
deploy
when
:
manual
extends
:
.surge
# Only deploy branches on surge
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
&&
$CI_COMMIT_BRANCH
!=
"master"'
when
:
manual
allow_failure
:
true
-
when
:
never
# Do not try to checkout the branch if it was deleted
variables
:
GIT_STRATEGY
:
none
environment
:
name
:
${CI_COMMIT_REF_SLUG}
url
:
https://${CI_COMMIT_REF_SLUG}-teklia.surge.sh
action
:
stop
before_script
:
-
npm install -g surge
script
:
-
surge teardown ${CI_ENVIRONMENT_URL}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment