forked from iamazeem/fluent-plugin-http-cwm
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (77 loc) · 2.58 KB
/
ci.yml
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
name: ci
on:
push:
paths-ignore:
- '**.md'
- '.rubocop.yml'
pull_request:
paths-ignore:
- '**.md'
- '.rubocop.yml'
jobs:
run-tests:
name: Run tests
strategy:
matrix:
os: [ubuntu-18.04]
ruby-version: ['2.5', '2.6', '2.7']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Bundle install
run: |
gem install bundler && \
bundle install --jobs 4 --retry 3
- name: Install Redis
run: sudo apt install redis-server
- name: Tests
run: bundle exec rake test
publish:
needs: "run-tests"
if: startsWith(github.ref, 'refs/tags/v')
name: Publish Gem
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: bundle install
- name: Build and publish RubyGem
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
run: |
mkdir -p $HOME/.gem && \
touch $HOME/.gem/credentials && \
chmod 0600 $HOME/.gem/credentials && \
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials && \
bin/update_version.sh "${GITHUB_REF#refs/tags/v}" &&\
gem build fluent-plugin-cwm-http.gemspec && \
gem push "fluent-plugin-cwm-http-${GITHUB_REF#refs/tags/v}.gem" && \
echo "Gem published successfully!"
- name: Update version file on CloudWebManage/cwm-worker-logger
env:
DEPLOY_KEY: ${{ secrets.CWM_WORKER_LOGGER_DEPLOY_KEY }}
DEPLOY_KEY_FILE: cwm_worker_logger_deploy_key
GEM_NAME: fluent-plugin-cwm-http
run: |
version="${GITHUB_REF#refs/tags/v}" && \
echo "Version: " $version && \
echo "$DEPLOY_KEY" > $DEPLOY_KEY_FILE && \
chmod 400 $DEPLOY_KEY_FILE && \
export GIT_SSH_COMMAND="ssh -i $(pwd)/$DEPLOY_KEY_FILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" && \
git clone [email protected]:CloudWebManage/cwm-worker-logger.git && \
cd cwm-worker-logger && \
git config user.name "$GEM_NAME CI" && \
git config user.email "$GEM_NAME-ci@localhost" && \
echo $version > $GEM_NAME.version && \
git add $GEM_NAME.version && \
git commit -m "Automatic version update for $GEM_NAME gem." && \
git push origin main && \
echo "Version updated successfully!"