Skip to content

Commit 3c9b7da

Browse files
committed
add gitlab ci
1 parent c1db643 commit 3c9b7da

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

.gitlab-ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
stages:
2+
- test
3+
- cleanup
4+
- tweet
5+
- deploy
6+
7+
test_job:
8+
stage: test
9+
script:
10+
- ci/wordpress_test
11+
12+
cleanup:
13+
stage: cleanup
14+
script:
15+
- ci/wordpress_cleanup
16+
when: always
17+
18+
tweet_succeed_job:
19+
variables:
20+
PASSED: "true"
21+
stage: tweet
22+
only:
23+
- tags
24+
- triggers
25+
- master
26+
script:
27+
- ci/wordpress_tweet
28+
29+
tweet_failed_job:
30+
variables:
31+
PASSED: "false"
32+
stage: tweet
33+
only:
34+
- tags
35+
- triggers
36+
- master
37+
script:
38+
- ci/wordpress_tweet
39+
when: on_failure
40+
41+
deploy_job:
42+
stage: deploy
43+
only:
44+
- tags
45+
- triggers
46+
- master
47+
script:
48+
- ci/wordpress_deploy

ci/lemp_cleanup

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
docker-compose down

ci/lemp_deploy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
git checkout master
6+
git push --mirror https://$GITHUB_TOKEN@github.com/Evild67/docker-compose-wordpress.git

ci/lemp_test

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
docker-compose up -d
6+
if docker ps | grep -q wordpress_nginx; then
7+
echo Docker nginx found
8+
else
9+
echo Docker nginx found
10+
exit
11+
fi
12+
13+
if docker ps | grep -q wordpress_php; then
14+
echo Docker php found
15+
else
16+
echo Docker php found
17+
exit
18+
fi
19+
20+
if docker ps | grep -q wordpress_mariadb; then
21+
echo Docker mariadb found
22+
else
23+
echo Docker mariadb found
24+
exit
25+
fi
26+
27+
28+
sleep 30
29+
curl -I 127.0.0.1

ci/lemp_tweet

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -e
3+
4+
default_text="Gitlab Job $CI_BUILD_ID :"
5+
6+
tweet_text="$default_text #Docker lemp_stack $CI_BUILD_REF_NAME build"
7+
8+
if [ $PASSED = true ]; then
9+
tweet_text="$tweet_text succeed"
10+
else
11+
tweet_text="$tweet_text failed"
12+
fi
13+
14+
docker run --rm -e TWITTER_ACCESS_TOKEN_SECRET=$TWITTER_ACCESS_TOKEN_SECRET -e TWITTER_ACCESS_TOKEN_KEY=$TWITTER_ACCESS_TOKEN_KEY -e TWITTER_CONSUMER_SECRET=$TWITTER_CONSUMER_SECRET -e TWITTER_CONSUMER_KEY=$TWITTER_CONSUMER_KEY evild/twitter_build_bot:latest "$tweet_text"

0 commit comments

Comments
 (0)