Skip to content

Commit

Permalink
Merge pull request #64 from technote-space/chore/chore-sync-workflows
Browse files Browse the repository at this point in the history
chore: sync workflows
  • Loading branch information
technote-space authored Feb 12, 2020
2 parents 41ee6c8 + 8e811bb commit 6411aca
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ categories:
labels:
- 'Type: Feature'
- 'Type: Refactoring'
- 'Type: CI/CD'
- title: ':bug: Bug Fixes'
labels:
- 'Type: Bug'
- 'Type: Security'
- title: ':wrench: Maintenance'
labels:
- 'Type: Maintenance'
- 'Type: CI/CD'
- title: ':green_book: Docs'
labels:
- 'Type: Documentation'
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/add-version-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
pull_request:
branches:
- master
types: [closed]

name: Add version tag

jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
steps:
- name: Get version
run: echo "::set-env name=TAG_NAME::${HEAD_REF#release/}"
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
- uses: actions/github-script@0.4.0
with:
github-token: ${{ secrets.ACCESS_TOKEN }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.TAG_NAME}`,
sha: context.sha
})
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
on: push

name: Check package version

jobs:
checkVersion:
name: Check package version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 3
- name: Check package version
uses: technote-space/package-version-check-action@v1
with:
Expand Down
197 changes: 161 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,119 +1,244 @@
on:
pull_request:
push:
branches:
- master
tags:
- "!*"
on: push

name: CI

jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest
env:
LINT: 1
steps:
- name: Set running flag
run: echo "::set-env name=RUNNING::1"
- uses: actions/checkout@v2
with:
fetch-depth: 3
- uses: technote-space/get-git-comment-action@v1
- uses: technote-space/get-diff-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREFIX_FILTER: |
src/
__tests__/
SUFFIX_FILTER: .ts
SUFFIX_FILTER: |
.js
.ts
FILES: .eslintrc
if: "! contains(env.COMMIT_MESSAGE, '[skip ci]') && ! contains(env.COMMIT_MESSAGE, '[ci skip]')"
- name: Set running flag
run: echo "::set-env name=RUNNING::"
if: "! env.GIT_DIFF"

- name: Get Yarn Cache Directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
if: env.GIT_DIFF
if: env.RUNNING
- name: Cache node dependencies
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
if: env.GIT_DIFF
if: env.RUNNING
- name: Install Package dependencies
run: yarn install
if: env.GIT_DIFF
if: env.RUNNING
- name: Check code style
run: yarn eslint ${{ env.GIT_DIFF }}
if: env.GIT_DIFF
- uses: 8398a7/action-slack@v1
if: env.RUNNING
- uses: 8398a7/action-slack@v2
with:
type: failure
status: failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()

jest:
name: Jest
cover:
name: Coverage
needs: eslint
runs-on: ubuntu-latest
strategy:
matrix:
node: ['10', '11', '12']
node: ['11', '12']
steps:
- name: Set running flag
run: echo "::set-env name=RUNNING::1"
- uses: actions/checkout@v2
with:
fetch-depth: 3
- uses: technote-space/get-git-comment-action@v1
- uses: technote-space/get-diff-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PREFIX_FILTER: |
src/
__tests__/
SUFFIX_FILTER: .ts
SUFFIX_FILTER: |
.js
.ts
.snap
FILES: |
yarn.lock
jest.config.js
if: "! contains(env.COMMIT_MESSAGE, '[skip ci]') && ! contains(env.COMMIT_MESSAGE, '[ci skip]')"
- name: Set running flag
run: echo "::set-env name=RUNNING::"
if: "! env.GIT_DIFF"
- name: Set running flag
if: matrix.node == '12' && startsWith(github.ref, 'refs/tags/')
run: echo "::set-env name=RUNNING::1"
- name: Set running flag
run: |
if [[ ! -f package.json ]] || ! < package.json jq -r '.scripts | keys[]' | grep -qe '^cover$'; then
echo "::set-env name=RUNNING::"
fi
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
if: env.GIT_DIFF || github.event_name == 'push'
if: env.RUNNING
- name: Get Yarn Cache Directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
if: env.GIT_DIFF || github.event_name == 'push'
if: env.RUNNING
- name: Cache node dependencies
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
if: env.GIT_DIFF || github.event_name == 'push'
if: env.RUNNING
- name: Install Package dependencies
run: yarn install
if: env.GIT_DIFF || github.event_name == 'push'
if: env.RUNNING
- name: Run tests
run: yarn cover
if: env.GIT_DIFF || github.event_name == 'push'
if: env.RUNNING
- name: Codecov
run: curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
run: |
if [ -n "$CODECOV_TOKEN" ]; then
curl -s https://codecov.io/bash | bash -s -- -t $CODECOV_TOKEN -f $COVERAGE_FILE
fi
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
COVERAGE_FILE: ./coverage/lcov.info
if: matrix.node == '12' && (env.GIT_DIFF || github.event_name == 'push')
- uses: 8398a7/action-slack@v1
if: env.RUNNING && matrix.node == '12'
- uses: 8398a7/action-slack@v2
with:
type: failure
status: failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()

slack:
name: Slack
needs: jest
package:
name: Publish Package
needs: cover
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
target: ['npm', 'gpr']
steps:
- uses: 8398a7/action-slack@v1
- name: Set running flag
run: echo "::set-env name=RUNNING::1"
- name: Set running flag
run: |
if [ -z "$NPM_AUTH_TOKEN" ]; then
echo "::set-env name=RUNNING::"
fi
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- uses: actions/checkout@v2
if: env.RUNNING
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
if: env.RUNNING && matrix.target == 'npm'
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com
if: env.RUNNING && matrix.target == 'gpr'
- name: Get Yarn Cache Directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
if: env.RUNNING
- name: Cache node dependencies
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
if: env.RUNNING
- name: Check package version
uses: technote-space/package-version-check-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_DISABLED: 1
if: env.RUNNING
- name: Install Package dependencies
run: yarn install
if: env.RUNNING
- name: Build
run: yarn build
if: env.RUNNING
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
npm publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
if: env.RUNNING && matrix.target == 'npm'
- name: Publish
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.RUNNING && matrix.target == 'gpr'
- uses: 8398a7/action-slack@v2
with:
status: failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()

publishRelease:
name: Create Release
needs: [package]
runs-on: ubuntu-latest
steps:
- name: Get version
run: echo "::set-env name=TAG_NAME::${HEAD_REF#refs/tags/}"
env:
HEAD_REF: ${{ github.ref }}
- name: Create Release
id: drafter
uses: technote-space/release-drafter@v6
with:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DRAFT: false
NAME: ${{ env.TAG_NAME }}
TAG: ${{ env.TAG_NAME }}
- uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
text: ${{ format('<{0}>', steps.drafter.outputs.html_url) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always() && steps.drafter.outputs.html_url
- uses: 8398a7/action-slack@v2
with:
type: success
status: ${{ job.status }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always() && ! steps.drafter.outputs.html_url
14 changes: 0 additions & 14 deletions .github/workflows/gh_releases.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
on:
issues:
types: [opened]

name: Issue opened

jobs:
assign:
name: Assign issues to project
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
on:
pull_request:
types: [opened]

name: Pull Request opened

jobs:
assignToProject:
name: Assign PullRequest to Project
Expand All @@ -28,6 +30,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: PR Labeler
uses: technote-fork/pr-labeler-action@v3
uses: technote-space/pr-labeler-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 6411aca

Please sign in to comment.