-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (101 loc) · 3.18 KB
/
main.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
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
119
120
121
122
123
name: netsoft-rubocop-main
on:
pull_request:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+.[0-9a-z]+
- v[0-9]+.[0-9]+.[0-9]+
env:
RUBYOPT: "-W:no-deprecated -W:no-experimental"
jobs:
rubocop:
name: Rubocop
runs-on: [self-hosted, ubuntu-t3.medium]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 1.0
- uses: actions/cache@v2
with:
path: $HOME/.cache/rubocop_cache
key: netsoft-rubocop-rubocop-${{ hashFiles('.rubocop.yml') }}
restore-keys: |
netsoft-rubocop-rubocop-${{ hashFiles('.rubocop.yml') }}
netsoft-rubocop-rubocop-
- name: Rubocop
shell: bash
run: |
bundle exec rubocop \
--parallel \
--format progress
publish:
name: Publish
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
needs: [ rubocop ]
runs-on: [self-hosted, ubuntu-t3.medium]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 1.0
- name: Get Tag Name
id: tag_name
shell: bash
run: |
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Tag Name Validation
shell: bash
env:
SOURCE_TAG: ${{ steps.tag_name.outputs.SOURCE_TAG }}
run: |
[ -z "$SOURCE_TAG" ] && { echo "Tag is empty"; exit 1;}
echo "We are on tag: [ ${SOURCE_TAG} ]"
- name: VERSION Validation
shell: bash
env:
SOURCE_TAG: ${{ steps.tag_name.outputs.SOURCE_TAG }}
run: |
version=$(grep VERSION lib/netsoft/rubocop/version.rb | sed -e "s/.*'\([^']*\)'.*/\1/")
[[ "v$version" == "$SOURCE_TAG" ]] && { echo "VERSION $version matches $SOURCE_TAG"; exit 0; }
[[ "v$version" != "$SOURCE_TAG" ]] && { echo "VERSION $version does not match $SOURCE_TAG"; exit 2; }
- name: Release Gem
shell: bash
env:
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
run: |
./bin/setup-rubygems.sh
rm -rf pkg
rake build
gem push pkg/*.gem
danger:
name: Run danger
if: github.event_name == 'pull_request' && always()
needs: [ rubocop ]
runs-on: [self-hosted, ubuntu-t3.medium]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install Danger
shell: bash
run: |
gem install netsoft-danger --no-document
- name: Run danger
shell: bash
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
run: |
danger