Helper scripts (#298)

* Added helper scripts

* Added commit tag to version tag to builds from master

* Restored script for Travis

* Restored script for Jenkins

* Restored script for Jenkins

* Restored script for Jenkins
This commit is contained in:
Jesus Federico 2018-10-16 14:28:21 -04:00 committed by GitHub
parent ec250f3ed5
commit 1617b7dba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 2 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ vendor/bundle
# Ignore environment configuration.
.env
env
# IDEs
.idea

2
Jenkinsfile vendored
View File

@ -61,7 +61,7 @@ volumes: [
withCredentials([file(credentialsId: 'cloud-datastore-user-account-creds', variable: 'FILE'), string(credentialsId: 'DOCKER_USER', variable: 'DOCKER_USER'), string(credentialsId: 'DOCKER_PASSWORD', variable: 'DOCKER_PASSWORD')]) {
sh "gcloud auth activate-service-account --key-file=$FILE"
if (stageBuild) {
sh "sed -i 's/VERSION =.*/VERSION = \"${gitBranch}\"/g' config/initializers/version.rb"
sh "sed -i 's/VERSION =.*/VERSION = \"${gitBranch} (${gitCommit.substring(7)})\"/g' config/initializers/version.rb"
sh "gcloud docker -- build -t ${imageTag} -t 'bigbluebutton/${appName}:master' . && gcloud docker -- push ${imageTag}"
sh "docker login -u $DOCKER_USER -p $DOCKER_PASSWORD"
sh "docker push 'bigbluebutton/${appName}:master'"

13
scripts/README.md Normal file
View File

@ -0,0 +1,13 @@
# Helpers
## Running automatic updates
```
sudo ln -s /root/greenlight/scripts/deploy.sh /usr/local/bin/greenlight-deploy
sudo cp /root/greenlight/scripts/greenlight-auto-deployer.service /etc/systemd/system/greenlight-auto-deployer.service
sudo cp /root/greenlight/scripts/greenlight-auto-deployer.timer /etc/systemd/system/greenlight-auto-deployer.timer
sudo systemctl daemon-reload
sudo systemctl enable greenlight-auto-deployer.service
sudo systemctl enable greenlight-auto-deployer.timer
sudo systemctl start greenlight-auto-deployer.timer
```

17
scripts/deploy.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
STATUS="Status: Downloaded newer image for bigbluebutton/greenlight:v2"
new_status=$(sudo docker pull bigbluebutton/greenlight:v2 | grep Status:)
echo $new_status
if [ "$STATUS" == "$new_status" ]
then
cd /home/ubuntu/greenlight
sudo docker-compose down
sudo docker rmi $(sudo docker images -f dangling=true -q)
sudo docker-compose up -d
fi
exit 0

View File

@ -0,0 +1,5 @@
[Unit]
Description=Greenlight Auto Deployer
[Service]
ExecStart=/bin/bash /usr/local/bin/greenlight-deploy

View File

@ -0,0 +1,12 @@
[Unit]
Description=Runs greenlight-deploy every minute
[Timer]
# Time to wait after booting before we run first time
OnBootSec=1min
# Time between running each consecutive time
OnUnitActiveSec=1m
Unit=greenlight-auto-deployer.service
[Install]
WantedBy=multi-user.target