Skip to content

Commit

Permalink
ci: merge publish workflow in main ci workflow, add helper workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime committed Nov 17, 2020
1 parent db04bc3 commit efd8b5a
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 105 deletions.
85 changes: 76 additions & 9 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
branches:
- master

jobs:
continuous-integration:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -29,24 +32,88 @@ jobs:
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install Dependencies
- name: ⚙️ Install Dependencies
run: yarn

- name: Build
- name: 🏗️ Build
run: yarn build

- name: Test
run: yarn test --coverage
- name: 🧪 Test
run: |
yarn lint
yarn test:coverage
env:
CI: true

- uses: codecov/codecov-action@v1
- name: 📊 Code coverage
uses: codecov/codecov-action@v1

publish:
needs: continuous-integration
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: ⚙️ Install Dependencies
run: yarn

- name: 🏗️ Build
run: |
yarn build
yarn build:doc
- name: 🔖 Prepare release
run: |
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
npx standard-version
echo `git add -A && git commit -m "chore: prepare release"`
git push --follow-tags origin master
mkdir -p /tmp
cp -R build/docs /tmp/publish
cp -R docs /tmp/publish/
- name: 🌐 Publish Github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /tmp/publish
enable_jekyll: true

- name: 📦 Publish NPM packages
run: npm publish --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Greetings

on: [pull_request, issues]

jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Hi, thank for reporting an issue, we will check it out very soon'
pr-message: 'Hi, thank you for creating your PR, we will check it out very soon'
19 changes: 19 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request]

jobs:
label:

runs-on: ubuntu-latest

steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
85 changes: 0 additions & 85 deletions .github/workflows/publish.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ typings/
# next.js build output
.next

/dist
/dist
/build
3 changes: 2 additions & 1 deletion __tests__/test-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

# But not these files...
!.gitignore
!package.json
!package.json
!yarn.lock
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
},
"scripts": {
"start": "yarn link && tsc-watch",
"build": "rimraf ./dist && yarn lint && tsc && yarn build:copy-templates",
"build": "rimraf ./dist && tsc && yarn build:copy-templates",
"build:copy-templates": "rimraf ./dist/**/*.template && cd src && copyfiles ./**/*.template ../dist/ && cd ..",
"build:doc": "rimraf -rf docs && typedoc",
"build:doc": "rimraf -rf build/docs && typedoc",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"test": "jest",
"test:coverage": "yarn test --coverage",
"postinstall": "ts-dev-tools install"
},
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ describe('App', () => {
`;

exports[`createComponent run should create expected components files 1`] = `
"import React, { FC } from 'react';
"import { FC } from 'react';
import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next';
interface ITestComponentProps { }
const TestComponent: FC<ITestComponentProps> = (props) => {
const { t } = useTranslation();
Expand All @@ -89,6 +91,7 @@ const TestComponent: FC<ITestComponentProps> = (props) => {
</>;
};
export default TestComponent;"
`;
Expand Down
Loading

0 comments on commit efd8b5a

Please sign in to comment.