Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Agroclim
AgroMetInfo
Documentation
Commits
d5e65f81
Commit
d5e65f81
authored
1 year ago
by
Olivier Maury
Browse files
Options
Downloads
Patches
Plain Diff
Créer un script de déploiement. refs www#1
parent
e8c4ae23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Script deploiement
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/deploy.sh
+88
-0
88 additions, 0 deletions
bin/deploy.sh
with
88 additions
and
0 deletions
bin/deploy.sh
0 → 100755
+
88
−
0
View file @
d5e65f81
#!/bin/bash
function
echo_bold_green
{
echo
-e
"
\0
33[32;1m"
$1
"
\0
33[0m"
;
}
function
echo_bold_red
{
echo
-e
"
\0
33[31;1m"
$1
"
\0
33[0m"
;
}
function
usage
{
echo
"
$0
-h shows usage"
echo
"
$0
-p deploy on pre-production"
echo
"
$0
-P deploy on production"
}
while
getopts
":pPh"
option
do
case
"
${
option
}
"
in
h
)
usage
exit
0
;;
p
)
COLOR
=
"
\0
33[33;1;7m"
DESTPATH
=
agrometinfo-preprod/
export
HUGO_ENV
=
preproduction
SERVER
=
proxy
;;
P
)
COLOR
=
"
\0
33[31;1;7m"
DESTPATH
=
""
export
HUGO_ENV
=
production
SERVER
=
agrometinfo-prod
;;
*
)
usage
exit
0
;;
esac
done
if
[
$OPTIND
-eq
1
]
;
then
echo_bold_red
"No argument were passed"
usage
exit
0
fi
DESTDIR
=
/var/www/html/
$DESTPATH
echo
-e
"Are you sure to deploy AgroMetInfo doc on
$COLOR$SERVER
\0
33[0m:
$COLOR$DESTDIR
\0
33[0m (
$COLOR$HUGO_ENV
\0
33[0m)? (y/N)"
read
-p
""
-n
1
-r
echo
if
[[
!
$REPLY
=
~ ^[Yy]
$
]]
;
then
echo
"Deployment is cancelled!"
;
exit
0
;
fi
echo_bold_green
"Check if
$SERVER
is available"
if
ping
-c1
-w3
$SERVER
>
/dev/null 2>&1
then
echo
OK
;
else
echo_bold_red
"ping on
$SERVER
did not respond, check VPN or host name or IP"
;
exit
1
;
fi
echo_bold_green
"Check if lychee is installed"
if
[
!
-f
bin/lychee
]
;
then
LYCHEETGZ
=
lychee-v0.12.0-x86_64-unknown-linux-gnu.tar.gz
echo_bold_green
"Getting Lychee to check help center"
mkdir
-p
~/tmp bin
if
[
!
-f
~/tmp/
$LYCHEETGZ
]
;
then
wget
"https://github.com/lycheeverse/lychee/releases/download/v0.12.0/
$LYCHEETGZ
"
-O
~/tmp/
$LYCHEETGZ
fi
tar
zxf ~/tmp/
$LYCHEETGZ
-C
bin
fi
echo_bold_green
"Cleaning public/..."
rm
-fr
public/
echo_bold_green
"Building site..."
hugo
echo_bold_green
"- Launching Hugo server..."
hugo server &
sleep
1
echo_bold_green
"- Checking links..."
bin/lychee http://localhost:1313/
if
[
$?
-ne
0
]
;
then
echo_bold_red
"Errors were found"
pkill hugo
exit
1
fi
rsync
-rvz
--delete
--copy-links
public/
$SERVER
:
$DESTDIR
echo_bold_green
"- Killing hugo..."
pkill hugo
echo_bold_green
"Deployment done."
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