Skip to content

Commit cf8a1f3

Browse files
chore: migrate to github actions (#123)
1 parent ecc0679 commit cf8a1f3

File tree

7 files changed

+114
-77
lines changed

7 files changed

+114
-77
lines changed

.github/workflows/go.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
name: golangci-lint
2-
on: [pull_request]
1+
name: Run linter
2+
on:
3+
push:
4+
branches: [ '*' ]
5+
pull_request:
6+
branches: [ main ]
37
jobs:
4-
golangci-lint:
8+
lint:
59
name: lint
610
runs-on: ubuntu-latest
711
steps:
@@ -10,8 +14,7 @@ jobs:
1014
with:
1115
fetch-depth: 0
1216
- name: golangci-lint
13-
uses: golangci/golangci-lint-action@v2.5.2
17+
uses: golangci/golangci-lint-action@v2
1418
with:
1519
version: latest
16-
github-token: ${{ secrets.github_token }}
1720
only-new-issues: true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish Docker
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
name: Publish Docker
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout twilio-go
14+
uses: actions/checkout@v2
15+
16+
- name: Login to Docker Hub
17+
uses: docker/login-action@v1
18+
with:
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_TOKEN }}
21+
22+
# The expression strips off the shortest match from the front of the string to yield just the tag name as the output
23+
- name: Get tagged version
24+
run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
25+
26+
- name: Build and Push image
27+
run: make docker-build docker-push
28+
29+
notify-on-failure:
30+
name: Slack notify on failure
31+
if: ${{ failure() }}
32+
needs: [ deploy ]
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: rtCamp/action-slack-notify@v2
36+
env:
37+
SLACK_COLOR: 'danger'
38+
SLACK_ICON_EMOJI: ':github:'
39+
SLACK_MESSAGE: ${{ format('Failed to deploy {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
40+
SLACK_TITLE: Deployment Failure
41+
SLACK_USERNAME: GitHub Actions
42+
SLACK_MSG_AUTHOR: twilio-dx
43+
SLACK_FOOTER: Posted automatically using GitHub Actions
44+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
45+
MSG_MINIMAL: true

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Run Tests
2+
on:
3+
push:
4+
branches: [ '*' ]
5+
pull_request:
6+
branches: [ main ]
7+
schedule:
8+
# Run automatically at 8AM PST Monday-Friday
9+
- cron: '0 15 * * 1-5'
10+
workflow_dispatch:
11+
12+
jobs:
13+
tests:
14+
name: Build & Test
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 20
17+
strategy:
18+
matrix:
19+
go: [ '1.15', '1.16' ]
20+
steps:
21+
- name: Setup Go environment
22+
uses: actions/setup-go@v2
23+
24+
- name: Checkout twilio-go
25+
uses: actions/checkout@v2
26+
27+
- name: Build
28+
run: make install
29+
30+
- name: Run Unit Tests
31+
run: make test
32+
33+
- name: Run Cluster Tests
34+
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging') && github.event_name != 'pull_request' }}
35+
env:
36+
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
37+
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
38+
TWILIO_FROM_NUMBER: ${{ secrets.TWILIO_FROM_NUMBER }}
39+
TWILIO_TO_NUMBER: ${{ secrets.TWILIO_TO_NUMBER }}
40+
run: make cluster-test
41+
42+
notify-on-failure:
43+
name: Slack notify on failure
44+
if: ${{ failure() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
45+
needs: [ tests ]
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: rtCamp/action-slack-notify@v2
49+
env:
50+
SLACK_COLOR: 'danger'
51+
SLACK_ICON_EMOJI: ':github:'
52+
SLACK_MESSAGE: ${{ format('Failed running build on {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
53+
SLACK_TITLE: Build Failure
54+
SLACK_USERNAME: GitHub Actions
55+
SLACK_MSG_AUTHOR: twilio-dx
56+
SLACK_FOOTER: Posted automatically using GitHub Actions
57+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
58+
MSG_MINIMAL: true

.travis.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ golint: govet
2727
API_DEFINITIONS_SHA=$(shell git log --oneline | grep Regenerated | head -n1 | cut -d ' ' -f 5)
2828
docker-build:
2929
docker build -t twilio/twilio-go .
30-
docker tag twilio/twilio-go twilio/twilio-go:${TRAVIS_TAG}
30+
docker tag twilio/twilio-go twilio/twilio-go:${GITHUB_TAG}
3131
docker tag twilio/twilio-go twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
3232
docker tag twilio/twilio-go twilio/twilio-go:latest
3333

3434
docker-push:
35-
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
36-
docker push twilio/twilio-go:${TRAVIS_TAG}
35+
docker push twilio/twilio-go:${GITHUB_TAG}
3736
docker push twilio/twilio-go:apidefs-${API_DEFINITIONS_SHA}
3837
docker push twilio/twilio-go:latest
3938

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# twilio-go
22

3-
[![Build Status](https://app.travis-ci.com/twilio/twilio-go.svg?branch=main)](https://travis-ci.com/twilio/twilio-go)
3+
[![Tests](https://github.com/twilio/twilio-go/actions/workflows/test.yml/badge.svg)](https://github.com/twilio/twilio-go/actions/workflows/test.yml)
44
[![PkgGoDev](https://pkg.go.dev/badge/github.com/twilio/twilio-go)](https://pkg.go.dev/github.com/twilio/twilio-go)
55
[![Release](https://img.shields.io/github/release/twilio/twilio-go.svg)](https://github.com/twilio/twilio-go/releases/latest)
66
[![Learn OSS Contribution in TwilioQuest](https://img.shields.io/static/v1?label=TwilioQuest&message=Learn%20to%20contribute%21&color=F22F46&labelColor=1f243c&style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAASFBMVEUAAAAZGRkcHBwjIyMoKCgAAABgYGBoaGiAgICMjIyzs7PJycnMzMzNzc3UoBfd3d3m5ubqrhfrMEDu7u739/f4vSb/3AD///9tbdyEAAAABXRSTlMAAAAAAMJrBrEAAAKoSURBVHgB7ZrRcuI6EESdyxXGYoNFvMD//+l2bSszRgyUYpFAsXOeiJGmj4NkuWx1Qeh+Ekl9DgEXOBwOx+Px5xyQhDykfgq4wG63MxxaR4ddIkg6Ul3g84vCIcjPBA5gmUMeXESrlukuoK33+33uID8TWeLAdOWsKpJYzwVMB7bOzYSGOciyUlXSn0/ABXTosJ1M1SbypZ4O4MbZuIDMU02PMbauhhHMHXbmebmALIiEbbbbbUrpF1gwE9kFfRNAJaP+FQEXCCTGyJ4ngDrjOFo3jEL5JdqjF/pueR4cCeCGgAtwmuRS6gDwaRiGvu+DMFwSBLTE3+jF8JyuV1okPZ+AC4hDFhCHyHQjdjPHUKFDlHSJkHQXMB3KpSwXNGJPcwwTdZiXlRN0gSp0zpWxNtM0beYE0nRH6QIbO7rawwXaBYz0j78gxjokDuv12gVeUuBD0MDi0OQCLvDaAho4juP1Q/jkAncXqIcCfd+7gAu4QLMACCLxpRsSuQh0igu0C9Svhi7weAGZg50L3IE3cai4IfkNZAC8dfdhsUD3CgKBVC9JE5ABAFzg4QL/taYPAAWrHdYcgfLaIgAXWJ7OV38n1LEF8tt2TH29E+QAoDoO5Ve/LtCQDmKM9kPbvCEBApK+IXzbcSJ0cIGF6e8gpcRhUDogWZ8JnaWjPXc/fNnBBUKRngiHgTUSivSzDRDgHZQOLvBQgf8rRt+VdBUUhwkU6VpJ+xcOwQUqZr+mR0kvBUgv6cB4+37hQAkXqE8PwGisGhJtN4xAHMzrsgvI7rccXqSvKh6jltGlrOHA3Xk1At3LC4QiPdX9/0ndHpGVvTjR4bZA1ypAKgVcwE5vx74ulwIugDt8e/X7JgfkucBMIAr26ndnB4UCLnDOqvteQsHlgX9N4A+c4cW3DXSPbwAAAABJRU5ErkJggg==)](https://twil.io/learn-open-source)

0 commit comments

Comments
 (0)