-
Notifications
You must be signed in to change notification settings - Fork 5
69 lines (57 loc) · 1.88 KB
/
main.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
name: ci
on:
pull_request:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup ruby and install deps
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
bundler: default
- name: Run lint
run: bundle exec rubocop
- name: Build plugin
run: bundle exec rake build
- name: Run tests
run: bundle exec rake test
- name: Capture version
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Verify tag version matchs VERSION file
# Only run this test when run on a tag
if: startsWith(github.ref, 'refs/tags/v')
# Fail if the tag name does not match the version in the VERSION file.
run: test "${{ github.ref }}" == "refs/tags/v${{ env.VERSION }}"
- name: Login to Docker Hub
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
username: scalyr
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
# set push to true when a tag is created
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
file: docker/Dockerfile
context: .
tags: |
scalyr/fluentd:latest
scalyr/fluentd:${{ env.VERSION }}
- name: Write RubyGems Credentials to a file
if: startsWith(github.ref, 'refs/tags/v')
run: ./scripts/set-up-rubygems-credentials.sh
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
- name: Publish package to RubyGems
if: startsWith(github.ref, 'refs/tags/v')
run: gem push pkg/fluent-plugin-scalyr-${{ env.VERSION }}.gem