-
Notifications
You must be signed in to change notification settings - Fork 60
/
generate-github.sh
executable file
·118 lines (99 loc) · 2.95 KB
/
generate-github.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e -x
if [ ${GITHUB_REF##*/} = "gh-pages" ]
then
exit
fi
rm -rf tmp/
mkdir tmp
mkdir tmp/assets
export RAILS_ENV=production
gem install bundler -v"1.17.3"
cd rails3
bundle install --jobs 4 --retry 3
bundle exec rake assets:precompile
bundle exec rake db:reset
bundle exec rake db:setup
bundle exec rails s &
sleep 10
wget -p http://localhost:3000/examples
kill %1
cp localhost\:3000/examples ../tmp/rails3.html
cp -rf localhost\:3000/assets/* ../tmp/assets/
rm -rf localhost\:3000
cd ..
echo "NOW RAILS 4"
cd rails4
bundle install --jobs 4 --retry 3
bundle exec rake assets:precompile
bundle exec rake db:reset
bundle exec rake db:setup
bundle exec rails s &
sleep 10
wget -p http://localhost:3000/examples
kill %1
cp localhost\:3000/examples ../tmp/rails4.html
cp -rf localhost\:3000/assets/* ../tmp/assets/
rm -rf localhost\:3000
cd ..
echo "NOW RAILS 5"
cd rails5
bundle install --jobs 4 --retry 3
export DISABLE_DATABASE_ENVIRONMENT_CHECK=1
RAILS_ENV=production bundle exec rails assets:clobber
RAILS_ENV=production bundle exec rails assets:precompile
rails db:environment:set RAILS_ENV=production
RAILS_ENV=production bundle exec rails db:reset
RAILS_ENV=production bundle exec rails db:setup
RAILS_ENV=production bundle exec rails s &
sleep 10
wget -p http://localhost:3000/examples
kill %1
cp localhost\:3000/examples ../tmp/rails5.html
cp localhost\:3000/examples ../tmp/index.html
cp -rf localhost\:3000/assets/* ../tmp/assets/
rm -rf localhost\:3000
cd ..
echo "NOW RAILS 6"
cd rails6
gem install bundler -v"2.2.21"
bundle install --jobs 4 --retry 3
RAILS_ENV=production bundle exec rails assets:clobber
RAILS_ENV=production bundle exec rails assets:precompile
RAILS_ENV=production rails db:environment:set RAILS_ENV=production
RAILS_ENV=production bundle exec rails db:schema:load
RAILS_ENV=production bundle exec rails db:seed
RAILS_ENV=production bundle exec rails s &
sleep 10
wget -p http://localhost:3000/examples
kill %1
cp localhost\:3000/examples ../tmp/rails6.html
cp localhost\:3000/examples ../tmp/index.html
cp -rf localhost\:3000/assets/* ../tmp/assets/
rm -rf localhost\:3000
cd ..
echo "Checking results"
test -f tmp/index.html
test -f tmp/rails3.html
test -f tmp/rails4.html
test -f tmp/rails5.html
test -f tmp/rails6.html
if [ ${GITHUB_REF##*/} = "master" ]
then
git reset --hard
git checkout gh-pages
rm -rf assets
mv tmp/* .
rm -rf tmp
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add index.html rails3.html rails4.html rails5.html rails6.html assets/
git -c user.name="GitHub Actions" -c user.email="[email protected]" commit \
--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" \
-m "Automated build at $(date -u)"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git push origin gh-pages
echo "Pushed changes to site"
else
echo "Build appears to have succeeded"
fi