From 2d5374aa9369ad9f34b2c6eb1f4854b2e4533d31 Mon Sep 17 00:00:00 2001 From: technote-space Date: Mon, 10 Feb 2020 15:48:52 +0000 Subject: [PATCH 1/3] chore: sync workflows --- .github/release-drafter.yml | 2 +- .github/workflows/add-version-tag.yml | 27 +++ .../{check_version.yml => check-version.yml} | 2 + .github/workflows/ci.yml | 161 +++++++++++++++--- .github/workflows/gh-releases.yml | 39 +++++ .github/workflows/gh_releases.yml | 14 -- .../{issue_opened.yml => issue-opened.yml} | 2 + .../{pr_opened.yml => pr-opened.yml} | 2 + .../{pr_updated.yml => pr-updated.yml} | 4 +- ..._card_moved.yml => project-card-moved.yml} | 2 + .github/workflows/release.yml | 110 ------------ 11 files changed, 212 insertions(+), 153 deletions(-) create mode 100644 .github/workflows/add-version-tag.yml rename .github/workflows/{check_version.yml => check-version.yml} (99%) create mode 100644 .github/workflows/gh-releases.yml 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} (99%) rename .github/workflows/{pr_updated.yml => pr-updated.yml} (95%) 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 a041c4d2..9fc1e3e7 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 00000000..37e9ad9d --- /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 99% rename from .github/workflows/check_version.yml rename to .github/workflows/check-version.yml index 37234090..16b0475f 100644 --- a/.github/workflows/check_version.yml +++ b/.github/workflows/check-version.yml @@ -1,5 +1,7 @@ on: push + name: Check package version + jobs: checkVersion: name: Check package version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62dbaef6..3bfe817e 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 @@ -15,20 +9,29 @@ 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: @@ -36,16 +39,16 @@ 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 }} @@ -57,31 +60,47 @@ 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: @@ -89,13 +108,13 @@ 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: | if [ -n "$CODECOV_TOKEN" ]; then @@ -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 diff --git a/.github/workflows/gh-releases.yml b/.github/workflows/gh-releases.yml new file mode 100644 index 00000000..db148af3 --- /dev/null +++ b/.github/workflows/gh-releases.yml @@ -0,0 +1,39 @@ +on: + push: + tags: + - "v*" + +name: GitHub Releases + +jobs: + releases: + name: Create Release + 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: steps.drafter.outputs.html_url + - uses: 8398a7/action-slack@v2 + with: + status: ${{ job.status }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + if: failure() diff --git a/.github/workflows/gh_releases.yml b/.github/workflows/gh_releases.yml deleted file mode 100644 index 3097a779..00000000 --- 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: release-drafter/release-drafter@v5 - 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 52b584d8..d00c9580 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 99% rename from .github/workflows/pr_opened.yml rename to .github/workflows/pr-opened.yml index 3645df75..731905a5 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 diff --git a/.github/workflows/pr_updated.yml b/.github/workflows/pr-updated.yml similarity index 95% rename from .github/workflows/pr_updated.yml rename to .github/workflows/pr-updated.yml index 39e24285..4e8daf49 100644 --- a/.github/workflows/pr_updated.yml +++ b/.github/workflows/pr-updated.yml @@ -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 @@ -50,4 +53,3 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} IGNORE_CONTEXT_CHECK: true - 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 fa64e8f3..25fae4b2 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 b999da59..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,110 +0,0 @@ -on: - push: - tags: - - 'v*' - -name: Release - -jobs: - test: - name: Test before release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - 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 - - 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: 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 }} From 888b62e8d5b2970e56f96154ea955148a4a237b7 Mon Sep 17 00:00:00 2001 From: technote-space Date: Mon, 10 Feb 2020 15:48:57 +0000 Subject: [PATCH 2/3] chore: trigger workflow From b9f8d59d7712178e4b1713921f8267fd80d88201 Mon Sep 17 00:00:00 2001 From: technote-space Date: Mon, 10 Feb 2020 15:55:58 +0000 Subject: [PATCH 3/3] chore: sync workflows --- .github/workflows/gh-releases.yml | 39 ------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/gh-releases.yml diff --git a/.github/workflows/gh-releases.yml b/.github/workflows/gh-releases.yml deleted file mode 100644 index db148af3..00000000 --- a/.github/workflows/gh-releases.yml +++ /dev/null @@ -1,39 +0,0 @@ -on: - push: - tags: - - "v*" - -name: GitHub Releases - -jobs: - releases: - name: Create Release - 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: steps.drafter.outputs.html_url - - uses: 8398a7/action-slack@v2 - with: - status: ${{ job.status }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: failure()