From 9c4ee828e7a3828ad37b5cb4146191e3a690bc15 Mon Sep 17 00:00:00 2001 From: Elise Shanholtz Date: Wed, 27 Oct 2021 12:52:38 -0700 Subject: [PATCH] chore: migrate from TravisCI to GitHub Actions (#702) --- .github/workflows/deploy.yml | 53 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 49 +++++++++++++++++++++++++++++++++ .travis.yml | 45 ------------------------------ 3 files changed, 102 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..4a2e31ebfe --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy +on: + push: + tags: + - '*' + workflow_dispatch: + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: Checkout twilio-node + 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 Node + uses: actions/setup-node@v2 + with: + node-version: 8 + registry-url: 'https://registry.npmsjs.org' + + - run: npm install + - name: Publish to NPM + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish + + 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: ${{ job.status }} + SLACK_ICON_EMOJI: ':github:' + SLACK_MESSAGE: ${{ format('Failed to deploy {1}{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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..28d84b019d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +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: + node: [6, 8, 10, lts/*] + steps: + - name: Checkout twilio-node + uses: actions/checkout@v2 + + - name: Set up Node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - run: npm install + - name: Run Unit Tests + run: npm run ci + + 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: ${{ job.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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5e246b4830..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: node_js -node_js: -- node -- lts/* -- '8' -- '6' -services: -- docker -jobs: - include: - - language: node_js - node_js: '10' - after_success: - - sonar-scanner -script: -- npm run ci -- if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" - == "false" ]; then echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" - --password-stdin; fi -deploy: -- provider: script - script: make docker-build && make docker-push - skip_cleanup: true - on: - tags: true - node: '8' -- provider: npm - email: team_interfaces@twilio.com - api_key: "$NPM_TOKEN" - on: - tags: true - node: '8' -notifications: - slack: - if: branch = main - on_pull_requests: false - on_success: never - on_failure: change - rooms: - secure: jQ2AF/kqOdO7HxO2y56yzLH2jIm/mvV1fprAEKo8NdLRXq3HRpFQbEumMlZRl8vr+BD173LYRmzm5C5Sk4ef9Nt+y6KJRWpGkkTYts/xSmmE30xVmRD7vzMQthjyPhwdp2EF/OP4hL1BQ+Xod2WSjaqJUTutFAZggB/Umfg+PBo= -addons: - sonarcloud: - organization: twilio - token: - secure: sbUfTjrbv95UVUpUDij2IRz5qCMvwWoLpKNHftamhyzy2v+xqxcHfn21FAwCriVPublYOv/sR1/sAcaMd+vvGd2SGGiSOMCTylvN3mLZXg5HfSfAMWLs0zDPtxKBSHZIbija3Ev7jTZtM9NuyodkJLxePSALn6DQ7ZcICZ5PCAM=