-
Notifications
You must be signed in to change notification settings - Fork 10
109 lines (96 loc) · 3.82 KB
/
ci-ruby.yaml
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
name: vaas-ruby-ci
on:
push:
branches:
- main
paths:
- "ruby/**"
- ".github/workflows/ci-ruby.yaml"
tags:
- "rb*"
pull_request:
branches:
- main
paths:
- "ruby/**"
- ".github/workflows/ci-ruby.yaml"
workflow_dispatch:
inputs:
environment:
type: choice
description: "Test environment"
options:
- production
- staging
default: "production"
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }}
VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }}
TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/rb')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }}
jobs:
build-ruby:
name: Build & Test Ruby SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1" # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: extract version
if: startsWith(github.ref, 'refs/tags/rb')
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/rb}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: set version
if: startsWith(github.ref, 'refs/tags/rb')
run: |
sed -i "s/VERSION = '0.0.1'/VERSION = '$RELEASE_VERSION'/g" ./ruby/lib/vaas/version.rb
- name: set version without tag
if: ${{ !startsWith(github.ref, 'refs/tags/rb') }}
run: |
echo RELEASE_VERSION=$(sed -r -n 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' ./ruby/lib/vaas/version.rb) >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: build gem
run: gem build vaas.gemspec
working-directory: ruby
- name: install dependencies/gem
run: |
echo $RELEASE_VERSION
gem install "vaas-$RELEASE_VERSION.gem"
working-directory: ruby
- name: Test
run: ruby vaas_test.rb
working-directory: ruby/test
- name: Run simple example
env:
URL: "https://github.com/GDATASoftwareAG/vaas"
run: ruby simple_example.rb
working-directory: ruby/examples
- name: Run example with reconnect
env:
URL: "https://github.com/GDATASoftwareAG/vaas"
run: ruby example_with_reconnect.rb
working-directory: ruby/examples
- name: Push to rubygems.org
if: startsWith(github.ref, 'refs/tags/rb')
env:
RUBY_GEMS_TOKEN: ${{ secrets.RUBY_GEMS_TOKEN }}
run: |
mkdir -p ~/.gem
cat << EOF > ~/.gem/credentials
---
:rubygems_api_key: ${RUBY_GEMS_TOKEN}
EOF
chmod 0600 ~/.gem/credentials
set -x
gem update --system
gem push "vaas-$RELEASE_VERSION.gem"
working-directory: ruby
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: failure()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
overwrite: "{title: `Failed workflow on for VaaS-SDK ${workflow}`, sections: [{activityTitle: 'build failed', activitySubtitle: `Failed workflow on for VaaS-SDK ${workflow}`, activityImage: 'https://adaptivecards.io/content/cats/3.png'}], themeColor: '#ff0000'}"