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 git@github.com: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!"