Skip to content

Commit

Permalink
Rework GitHub Actions / release only on merges
Browse files Browse the repository at this point in the history
With this PR we rework our GitHub actions and split them into two. One
is triggered for pull requests and executes our tests. The second one
runs for merges onto master. It executes the test as well but also
builds the docker image and pushes it to DockerHub.
  • Loading branch information
bastelfreak committed Sep 30, 2020
1 parent c43abe9 commit 4094c1f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby
name: test-build-release

on:
push:
branches: [ master ]
branches: master
pull_request:
branches: [ master ]
branches: master

jobs:
test:
Expand Down Expand Up @@ -41,22 +41,23 @@ jobs:
bundle install
- name: Run tests
run: bundle exec rake rubocop
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: voxpupuli/vox-pupuli-tasks
add_git_labels: true
tags: latest
tag_with_ref: true
tag_with_sha: true
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: voxpupuli/vox-pupuli-tasks
add_git_labels: true
tag_with_ref: true
push: ${{ startsWith(github.ref, 'refs/tags/') }}
41 changes: 41 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: test-build

on:
pull_request:
branches: master

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
with:
ruby-version: 2.7
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install dependencies
run: |
bundle config set path vendor/bundle
bundle config set jobs $(nproc)
bundle config set without development
bundle install
- name: Run tests
run: bundle exec rake rubocop

0 comments on commit 4094c1f

Please sign in to comment.