Skip to content

Commit

Permalink
Merge pull request #230 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 10, 2020
2 parents 445350e + b9f8d59 commit ae61b55
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 153 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/[email protected]
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,5 +1,7 @@
on: push

name: Check package version

jobs:
checkVersion:
name: Check package version
Expand Down
161 changes: 134 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
on:
pull_request:
push:
branches:
- master
tags:
- "!*"
on: push

name: CI

Expand All @@ -15,37 +9,46 @@ jobs:
env:
LINT: 1
steps:
- name: Set running flag
run: echo "::set-env name=RUNNING::1"
- uses: actions/checkout@v2
- 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 }}
Expand All @@ -57,45 +60,61 @@ jobs:
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
- 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: |
.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: |
if [ -n "$CODECOV_TOKEN" ]; then
Expand All @@ -104,23 +123,111 @@ jobs:
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
package:
name: Publish Package
needs: jest
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
target: ['npm', 'gpr']
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
if: matrix.target == 'npm'
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com
if: matrix.target == 'gpr'
- name: Get Yarn Cache Directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- 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-
- name: Check package version
uses: technote-space/package-version-check-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_DISABLED: 1
- name: Install Package dependencies
run: yarn install
- name: Build
run: yarn build
- name: Publish
run: |
if [ -n "$NPM_AUTH_TOKEN" ]; then
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
npm publish
fi
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
if: matrix.target == 'npm'
- name: Publish
run: |
if [ -n "$NPM_AUTH_TOKEN" ]; then
npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: 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:
- uses: 8398a7/action-slack@v1
- 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 Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
on: pull_request

name: Pull Request updated

jobs:
triage:
name: Pull Request Labeler
runs-on: ubuntu-latest
if: "! startsWith(github.event.pull_request.head.ref, 'release/v')"
steps:
- name: Pull Request Labeler
uses: actions/labeler@v2
Expand Down Expand Up @@ -50,4 +53,3 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORE_CONTEXT_CHECK: true

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

name: Project Card Event

jobs:
triage:
name: Auto card labeler
Expand Down
Loading

0 comments on commit ae61b55

Please sign in to comment.