Switch from Travis CI to GitHub Actions (#4126)

* Add GitHub Actions workflow for verification

Add a GitHub Actions workflow file that does the verification of pushes
and pull requests. I.e., it runs the linters, runs the tests, and builds
the website. This workflow runs for all `pull_requests` and `push`es.

* Add GitHub Actions workflow for deployment

Add a GitHub Actions workflow file that does the deployment upon pushes
to master. Before actually deploying, the linters and test are ran, just
in case.

* Remove Travis CI configuration file

* Remove unnecessary quotes from existing workflows

* Add caching for "Build website" verification

* Update build badge in README

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
This commit is contained in:
Eric Cornelissen 2020-11-28 11:34:36 +01:00 committed by GitHub
parent 9f4a056e14
commit c21487f4d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 138 additions and 76 deletions

View File

@ -1,4 +1,4 @@
name: "Pull Request Labeler"
name: Pull Request Labeler
on:
pull_request_target:
types: [opened]
@ -9,4 +9,4 @@ jobs:
steps:
- uses: ericcornelissen/labeler@label-based-on-status
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
repo-token: ${{ secrets.GITHUB_TOKEN }}

73
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: Publish
on:
push:
branches:
- master
jobs:
npm:
name: NPM Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Sanity check
run: |
npm run lint
npm run test
- name: Deploy to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
github:
name: GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Sanity check
run: |
npm run lint
npm run test
- name: Get commit message (for release title and body)
id: commit
uses: kceb/git-message-action@v1
- name: Get release title and body
id: release
run: |
RELEASE_TITLE=$(echo '${{ steps.commit.outputs.git-message }}' | head -n 1)
echo "::set-output name=title::$RELEASE_TITLE"
RELEASE_BODY=$(echo '${{ steps.commit.outputs.git-message }}' | tail -n $(expr $(echo '${{ steps.commit.outputs.git-message }}' | wc -l) - 1))
echo "::set-output name=body::$RELEASE_BODY"
- name: Get release version
id: get_version
run: |
export PACKAGE_VERSION=$(cat package.json | grep 'version' | sed 's/[ \",:]//g' | sed 's/version//')
echo "::set-output name=version::$PACKAGE_VERSION"
- name: Create and push git tag
uses: actions-ecosystem/action-push-tag@v1
with:
tag: ${{ steps.get_version.outputs.version }}
message: ${{ steps.commit.outputs.git-message }}
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.release.outputs.title }}
body: ${{ steps.release.outputs.body }}
draft: false
prerelease: false

View File

@ -1,4 +1,4 @@
name: "Automated releases"
name: Automated releases
on:
pull_request_review:
types: [submitted]
@ -13,4 +13,4 @@ jobs:
steps:
- uses: simple-icons/release-action@master
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
repo-token: ${{ secrets.GITHUB_TOKEN }}

60
.github/workflows/verify.yml vendored Normal file
View File

@ -0,0 +1,60 @@
name: Verify
on: [pull_request, push]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Run linter
run: |
npm run jsonlint
npm run svglint
npm run wslint
npm run our-lint
build:
name: Build website
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Ruby 2.5
uses: actions/setup-ruby@v1
with:
ruby-version: 2.5
- name: Setup cache for gems
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Jekyll
run: |
echo -e 'source "https://rubygems.org"\n\ngem "jekyll"' > Gemfile
bundle config set path 'vendor/bundle'
bundle install --jobs 4 --retry 3
- name: Build website
run: bundle exec jekyll build
test:
name: Test package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test

View File

@ -1,71 +0,0 @@
os: linux
jobs:
include:
- stage: "Test"
name: "Lint"
language: node_js
node_js: 12
git:
depth: 1
script:
- npm run jsonlint
- npm run svglint
- npm run wslint
- npm run our-lint
- name: "Build website"
language: ruby
rvm: 2.5.3
git:
depth: 1
cache:
directories:
- /home/travis/.rvm/
install:
- gem install jekyll
script:
- jekyll build
- name: "Test package"
language: node_js
node_js: 12
git:
depth: 1
script:
- npm run test
- stage: "Deploy"
name: "Git tag"
language: shell
git:
depth: 1
if: branch = master
before_deploy:
- git config --local user.name "$GITHUB_USERNAME"
- git config --local user.email "$GITHUB_EMAIL"
- export PACKAGE_VERSION=$(cat package.json | grep 'version' | sed 's/[ \",:]//g' | sed 's/version//')
- git tag $PACKAGE_VERSION
deploy:
provider: releases
token: "$GITHUB_TOKEN"
cleanup: false
- name: "NPM Package"
language: node_js
node_js: 12
git:
depth: 1
if: branch = master
deploy:
edge: true
provider: npm
email: "$NPM_EMAIL"
api_token: "$NPM_KEY"
cleanup: false
on:
branch: master
notifications:
email:
on_success: never
on_failure: change

View File

@ -141,6 +141,6 @@ Icons are also available as a [WordPress plugin](https://wordpress.org/plugins/s
## Status
[![Build Status](https://travis-ci.com/simple-icons/simple-icons.svg?branch=develop)](https://travis-ci.com/simple-icons/simple-icons)
[![Build status](https://github.com/simple-icons/simple-icons/workflows/Verify/badge.svg)](https://github.com/simple-icons/simple-icons/actions?query=workflow%3AVerify+branch%3Adevelop)
[![npm version](https://img.shields.io/npm/v/simple-icons.svg)](https://www.npmjs.com/package/simple-icons)
[![Packagist version](https://img.shields.io/packagist/v/simple-icons/simple-icons)](https://packagist.org/packages/simple-icons/simple-icons)