From b4a25667085b6119831c878b713b17d2a3e93300 Mon Sep 17 00:00:00 2001 From: technote-space Date: Wed, 12 Feb 2020 05:02:41 +0000 Subject: [PATCH 1/2] chore: sync workflows --- .github/release-drafter.yml | 2 +- .github/workflows/add-version-tag.yml | 27 +++ .../{check_version.yml => check-version.yml} | 4 +- .github/workflows/ci.yml | 197 ++++++++++++++---- .github/workflows/gh_releases.yml | 14 -- .../{issue_opened.yml => issue-opened.yml} | 2 + .../{pr_opened.yml => pr-opened.yml} | 4 +- .github/workflows/pr-updated.yml | 55 +++++ .github/workflows/pr_updated.yml | 11 - ..._card_moved.yml => project-card-moved.yml} | 2 + .github/workflows/release.yml | 112 ---------- .github/workflows/toc.yml | 4 + .github/workflows/update-dependencies.yml | 9 +- 13 files changed, 263 insertions(+), 180 deletions(-) create mode 100644 .github/workflows/add-version-tag.yml rename .github/workflows/{check_version.yml => check-version.yml} (90%) delete mode 100644 .github/workflows/gh_releases.yml rename .github/workflows/{issue_opened.yml => issue-opened.yml} (99%) rename .github/workflows/{pr_opened.yml => pr-opened.yml} (93%) create mode 100644 .github/workflows/pr-updated.yml delete mode 100644 .github/workflows/pr_updated.yml rename .github/workflows/{project_card_moved.yml => project-card-moved.yml} (99%) delete mode 100644 .github/workflows/release.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index a041c4d..9fc1e3e 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -6,7 +6,6 @@ categories: labels: - 'Type: Feature' - 'Type: Refactoring' - - 'Type: CI/CD' - title: ':bug: Bug Fixes' labels: - 'Type: Bug' @@ -14,6 +13,7 @@ categories: - title: ':wrench: Maintenance' labels: - 'Type: Maintenance' + - 'Type: CI/CD' - title: ':green_book: Docs' labels: - 'Type: Documentation' diff --git a/.github/workflows/add-version-tag.yml b/.github/workflows/add-version-tag.yml new file mode 100644 index 0000000..37e9ad9 --- /dev/null +++ b/.github/workflows/add-version-tag.yml @@ -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 + }) diff --git a/.github/workflows/check_version.yml b/.github/workflows/check-version.yml similarity index 90% rename from .github/workflows/check_version.yml rename to .github/workflows/check-version.yml index 04d85fa..16b0475 100644 --- a/.github/workflows/check_version.yml +++ b/.github/workflows/check-version.yml @@ -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: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 721a42c..abd99cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,4 @@ -on: - pull_request: - push: - branches: - - master - tags: - - "!*" +on: push name: CI @@ -12,21 +6,32 @@ 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: @@ -34,50 +39,68 @@ jobs: 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: @@ -85,35 +108,137 @@ jobs: 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 diff --git a/.github/workflows/gh_releases.yml b/.github/workflows/gh_releases.yml deleted file mode 100644 index 8c8fe7e..0000000 --- a/.github/workflows/gh_releases.yml +++ /dev/null @@ -1,14 +0,0 @@ -on: - push: - branches: - - master -name: GitHub Releases -jobs: - draftRelease: - name: Draft Release - runs-on: ubuntu-latest - steps: - - name: Draft Release - uses: toolmantim/release-drafter@v5.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/issue_opened.yml b/.github/workflows/issue-opened.yml similarity index 99% rename from .github/workflows/issue_opened.yml rename to .github/workflows/issue-opened.yml index 52b584d..d00c958 100644 --- a/.github/workflows/issue_opened.yml +++ b/.github/workflows/issue-opened.yml @@ -1,7 +1,9 @@ on: issues: types: [opened] + name: Issue opened + jobs: assign: name: Assign issues to project diff --git a/.github/workflows/pr_opened.yml b/.github/workflows/pr-opened.yml similarity index 93% rename from .github/workflows/pr_opened.yml rename to .github/workflows/pr-opened.yml index bbda2c6..731905a 100644 --- a/.github/workflows/pr_opened.yml +++ b/.github/workflows/pr-opened.yml @@ -1,7 +1,9 @@ on: pull_request: types: [opened] + name: Pull Request opened + jobs: assignToProject: name: Assign PullRequest to Project @@ -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 }} diff --git a/.github/workflows/pr-updated.yml b/.github/workflows/pr-updated.yml new file mode 100644 index 0000000..4e8daf4 --- /dev/null +++ b/.github/workflows/pr-updated.yml @@ -0,0 +1,55 @@ +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 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + assignToProject: + name: Assign PullRequest to Project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-git-comment-action@v1 + - name: Assign PullRequest to Project + if: contains(env.COMMIT_MESSAGE, 'trigger workflow') + uses: technote-space/create-project-card-action@v1 + with: + PROJECT: Backlog + COLUMN: To do + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IGNORE_CONTEXT_CHECK: true + + assignAuthor: + name: Assign author to PR + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-git-comment-action@v1 + - name: Assign Author to PR + if: contains(env.COMMIT_MESSAGE, 'trigger workflow') + uses: technote-space/assign-author@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IGNORE_CONTEXT_CHECK: true + + addLabelsByBranch: + name: PR Labeler + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-git-comment-action@v1 + - name: PR Labeler + if: contains(env.COMMIT_MESSAGE, 'trigger workflow') + uses: technote-space/pr-labeler-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + IGNORE_CONTEXT_CHECK: true diff --git a/.github/workflows/pr_updated.yml b/.github/workflows/pr_updated.yml deleted file mode 100644 index 14c5743..0000000 --- a/.github/workflows/pr_updated.yml +++ /dev/null @@ -1,11 +0,0 @@ -on: pull_request -name: Pull Request updated -jobs: - triage: - name: Pull Request Labeler - runs-on: ubuntu-latest - steps: - - name: Pull Request Labeler - uses: actions/labeler@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/project_card_moved.yml b/.github/workflows/project-card-moved.yml similarity index 99% rename from .github/workflows/project_card_moved.yml rename to .github/workflows/project-card-moved.yml index fa64e8f..25fae4b 100644 --- a/.github/workflows/project_card_moved.yml +++ b/.github/workflows/project-card-moved.yml @@ -1,7 +1,9 @@ on: project_card: types: [moved] + name: Project Card Event + jobs: triage: name: Auto card labeler diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 36e283c..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,112 +0,0 @@ -on: - push: - tags: - - 'v*' - -name: Publish Package - -jobs: - test: - name: Test before publish - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 3 - - 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: Install Package dependencies - run: yarn install - - name: Test - run: yarn test - - uses: 8398a7/action-slack@v1 - with: - type: failure - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: failure() - - release: - name: Publish Package - runs-on: ubuntu-latest - strategy: - matrix: - target: ['npm', 'gpr'] - needs: test - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 3 - - 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: | - npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN - npm publish - env: - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - if: matrix.target == 'npm' - - name: Publish - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: matrix.target == 'gpr' - - uses: 8398a7/action-slack@v1 - with: - type: failure - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: failure() - - slack: - name: Slack - needs: release - runs-on: ubuntu-latest - steps: - - uses: 8398a7/action-slack@v1 - with: - type: success - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/toc.yml b/.github/workflows/toc.yml index 2d4aded..825d767 100644 --- a/.github/workflows/toc.yml +++ b/.github/workflows/toc.yml @@ -13,4 +13,8 @@ jobs: uses: technote-space/toc-generator@v2 with: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + API_TOKEN: ${{ secrets.GITHUB_TOKEN }} TARGET_BRANCH_PREFIX: release/ + FOLDING: true + MAX_HEADER_LEVEL: 3 + TOC_TITLE: Details diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index bba5570..14407a1 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -1,12 +1,14 @@ on: schedule: - - cron: 0 17 * * 5 + - cron: 0 9 * * 1 pull_request: - types: [opened, synchronize, reopened, closed] + types: [opened, reopened, closed] + repository_dispatch: + types: [update-deps] name: Update dependencies jobs: - release: + update: name: Update npm dependencies runs-on: ubuntu-latest steps: @@ -14,6 +16,7 @@ jobs: uses: technote-space/create-pr-action@v1 with: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + API_TOKEN: ${{ secrets.GITHUB_TOKEN }} EXECUTE_COMMANDS: | npx npm-check-updates -u --packageFile package.json yarn install From 8e811bb7e813974809d0a7c40818ca35df52ccbf Mon Sep 17 00:00:00 2001 From: technote-space Date: Wed, 12 Feb 2020 05:02:45 +0000 Subject: [PATCH 2/2] chore: trigger workflow