Skip to content

Commit

Permalink
chore: migrate twilio-ruby to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz committed Oct 28, 2021
1 parent bebd646 commit 4ec5001
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy
on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
deploy:
name: Deploy to Rubygems
runs-on: ubuntu-latest
steps:
- name: Checkout twilio-ruby
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTH_TOKEN }}

- name: Build and Push image
run: make docker-build && make docker-push

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
bundler-cache: true

- run: bundle install --without-development
- name: Publish to Rubygems
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
gem build *.gemspec
gem push *.gem
notify-on-failure:
name: Slack notify on failure
if: ${{ failure() }}
needs: [deploy]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ needs.deploy.status }}
SLACK_ICON_EMOJI: ':github:'
SLACK_MESSAGE: ${{ format('Failed to publish {1} to RubyGems{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
SLACK_TITLE: Deployment Failure
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
SLACK_FOOTER: Posted automatically using GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests
on:
push:
branches: [ '*' ]
pull_request:
branches: [ main ]
schedule:
# Run automatically at 8AM PST Monday-Friday
- cron: '0 15 * * 1-5'
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
ruby: [2.4, 2.5, 2.6, 2.7, '3.0', ruby-head, jruby-9.2]
steps:
- name: Checkout twilio-ruby
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: bundle install --with development
- run: bundle exec rake install
- name: Run Unit Tests
run: make test

notify-on-failure:
name: Slack notify on failure
if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ needs.test.status }}
SLACK_ICON_EMOJI: ':github:'
SLACK_MESSAGE: ${{ format('Build {2} in {1} failed{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
SLACK_TITLE: Build Failure
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
SLACK_FOOTER: Posted automatically using GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true

0 comments on commit 4ec5001

Please sign in to comment.