diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 387aae2..815915e 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -16,11 +16,11 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PAT }} with: path-to-signatures: cla-signatures.json - path-to-cla-document: https://github.com/koj-co/.github/blob/master/CLA.md + path-to-document: https://github.com/koj-co/.github/blob/master/CLA.md allowlist: dependabot-preview[bot], dependabot[bot], greenkeeper[bot], *bot, bot* remote-organization-name: koj-co remote-repository-name: .github - signed-commit-message: ":wrench: @$contributorName has signed the CLA in #$pullRequestNo" create-file-commit-message: ":wrench: Creating a file for storing CLA signatures" + signed-commit-message: ":wrench: @$contributorName has signed the CLA in #$pullRequestNo" custom-allsigned-prcomment: "✍️ All contributors have signed the CLA" - custom-notsigned-prcomment: "Thanks for your submission! We ask that $you sign our [Contributor License Agreement]($pathToCLADocument) before we can accept your contribution. You can sign the CLA by adding a comment below using this text:" + custom-notsigned-prcomment: "Thanks for your submission! We ask that $you sign our [Contributor License Agreement](https://github.com/koj-co/.github/blob/master/CLA.md) before we can accept your contribution. You can sign the CLA by adding a comment below using this text:" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..16cfdd2 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,35 @@ +name: CodeQL CI +on: + schedule: + - cron: '0 0 * * 1' +jobs: + release: + name: Build and analyze + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + - name: Setup Node.js + uses: actions/setup-node@v2.1.2 + with: + node-version: 14 + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: javascript + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install dependencies + run: npm ci + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..ecb1772 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,15 @@ +name: Dependabot PR CI +on: + schedule: + - cron: "0 */6 * * *" + workflow_dispatch: +jobs: + label-approve: + name: Label and approve minor/patch updates + runs-on: ubuntu-18.04 + steps: + - uses: koj-co/dependabot-pr-action@master + with: + token: ${{ secrets.GH_PAT }} + merge-minor: true + merge-patch: true diff --git a/.github/workflows/hotfix-pr.yml b/.github/workflows/hotfix-pr.yml deleted file mode 100644 index 49f2a5e..0000000 --- a/.github/workflows/hotfix-pr.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Hotfix Branch Pull Request -on: - push: - branches-ignore: - - master - - production -jobs: - auto-pull-request: - name: PullRequestAction - runs-on: ubuntu-latest - steps: - - name: Generate branch name - uses: actions/github-script@v3 - id: set-branch-name - with: - script: | - const capitalize = (name) => name.charAt(0).toUpperCase() + name.slice(1); - const emoji = context.payload.ref.startsWith("refs/heads/feature") - ? "✨ " - : context.payload.ref.startsWith("refs/heads/hotfix") - ? "🚑 " - : ""; - return `${emoji}${capitalize( - context.payload.ref - .replace("refs/heads/", "") - .replace(/-/g, " ") - .replace("feature ", "") - .replace("hotfix ", "") - )}`; - result-encoding: string - - name: Set branch name - run: echo "PULL_REQUEST_TITLE=${{steps.set-branch-name.outputs.result}}" >> $GITHUB_ENV - - name: Generate PR body - uses: actions/github-script@v3 - id: set-pr-body - with: - script: | - return `I'm opening this pull request for this branch, pushed by @${ - context.payload.head_commit.author.username - } with ${context.payload.commits.length} commit${ - context.payload.commits.length === 1 ? "" : "s" - }.`; - result-encoding: string - - name: Set PR body - run: echo "PULL_REQUEST_BODY=${{steps.set-pr-body.outputs.result}}" >> $GITHUB_ENV - - name: pull-request-action - uses: vsoch/pull-request-action@1.0.11 - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - BRANCH_PREFIX: "hotfix-" - PULL_REQUEST_BRANCH: "production" - PULL_REQUEST_REVIEWERS: "AnandChowdhary" diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml deleted file mode 100644 index 1df54e2..0000000 --- a/.github/workflows/licensed.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: License CI -on: - push: - branches: - - master -jobs: - test: - runs-on: ubuntu-latest - name: Check licenses - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - name: Setup license - uses: jonabc/setup-licensed@v1.0.1 - with: - version: 2.x - - run: npm ci - - id: licensed - uses: jonabc/licensed-ci@v1 - with: - config_file: .github/licensed.yml - github_token: ${{ secrets.GH_PAT }} - user_name: "Koj Bot" - user_email: "bot@koj.co" - commit_message: ":page_facing_up: Update dependency license file" - - uses: actions/github-script@v3 - if: always() && steps.licensed.outputs.pr_number - with: - github-token: ${{ secrets.GH_PAT }} - script: | - github.issues.createComment({ - ...context.repo, - issue_number: ${{ steps.licensed.outputs.pr_number }} - body: "I've checked the license of your new dependency and it looks good!" - }) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index b4f22f4..73df10c 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -15,6 +15,21 @@ jobs: uses: actions/setup-node@v2.1.2 with: node-version: 14 + - name: Setup Licensed + uses: jonabc/setup-licensed@v1.0.1 + with: + version: 2.x + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: Install dependencies run: npm ci - name: Build TypeScript @@ -30,3 +45,23 @@ jobs: GIT_AUTHOR_EMAIL: "bot@koj.co" GIT_COMMITTER_NAME: "Koj Bot" GIT_COMMITTER_EMAIL: "bot@koj.co" + - name: Check dependency licenses + id: licensed + uses: jonabc/licensed-ci@v1 + with: + config_file: .github/licensed.yml + github_token: ${{ secrets.GH_PAT }} + user_name: "KojBot" + user_email: "bot@koj.co" + commit_message: ":page_facing_up: Update dependency license file [skip ci]" + - name: Add PR comment + uses: actions/github-script@v3 + if: always() && steps.licensed.outputs.pr_number + with: + github-token: ${{ secrets.GH_PAT }} + script: | + github.issues.createComment({ + ...context.repo, + issue_number: ${{ steps.licensed.outputs.pr_number }} + body: "I've checked the license of your new dependency and it looks good!" + }) diff --git a/.github/workflows/feature-pr.yml b/.github/workflows/pull-request.yml similarity index 65% rename from .github/workflows/feature-pr.yml rename to .github/workflows/pull-request.yml index 5219a10..6bf3dd6 100644 --- a/.github/workflows/feature-pr.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: Feature Branch Pull Request +name: PR Generator CI on: push: branches-ignore: @@ -19,12 +19,15 @@ jobs: ? "✨ " : context.payload.ref.startsWith("refs/heads/hotfix") ? "🚑 " + : context.payload.ref.startsWith("refs/heads/bug") + ? "🐛 " : ""; return `${emoji}${capitalize( context.payload.ref .replace("refs/heads/", "") .replace(/-/g, " ") .replace("feature ", "") + .replace("bug ", "") .replace("hotfix ", "") )}`; result-encoding: string @@ -43,11 +46,28 @@ jobs: result-encoding: string - name: Set PR body run: echo "PULL_REQUEST_BODY=${{steps.set-pr-body.outputs.result}}" >> $GITHUB_ENV + - name: Generate PR draft + uses: actions/github-script@v3 + id: set-pr-draft + with: + script: | + return !context.payload.ref.startsWith("refs/heads/hotfix"); + - name: Set PR draft + run: echo "PULL_REQUEST_DRAFT=${{steps.set-pr-draft.outputs.result}}" >> $GITHUB_ENV + - name: Determine whether to merge + uses: actions/github-script@v3 + id: should-pr + with: + github-token: ${{ secrets.GH_PAT }} + script: | + return + context.payload.ref.startsWith("refs/heads/feature") || + context.payload.ref.startsWith("refs/heads/hotfix") || + context.payload.ref.startsWith("refs/heads/bug"); - name: pull-request-action uses: vsoch/pull-request-action@1.0.11 + if: always() && steps.should-pr.outputs.result env: GITHUB_TOKEN: ${{ secrets.GH_PAT }} - BRANCH_PREFIX: "feature-" PULL_REQUEST_BRANCH: "master" PULL_REQUEST_REVIEWERS: "AnandChowdhary" - PULL_REQUEST_DRAFT: true diff --git a/.github/workflows/release-scheduler.yml b/.github/workflows/release-scheduler.yml new file mode 100644 index 0000000..466e021 --- /dev/null +++ b/.github/workflows/release-scheduler.yml @@ -0,0 +1,13 @@ +name: Release Scheduler CI +on: + schedule: + - cron: "0 0 * * 1" + workflow_dispatch: +jobs: + releaseScheduler: + runs-on: ubuntu-latest + steps: + - name: Run release-scheduler + uses: koj-co/release-scheduler@master + env: + GH_PAT: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4304a0a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Test CI +on: + push: + branches-ignore: + - master +jobs: + release: + name: Build and test + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + - name: Setup Node.js + uses: actions/setup-node@v2.1.2 + with: + node-version: 14 + - name: Install dependencies + run: npm ci + - name: Build TypeScript + run: npm run build + - name: Run tests + run: npm run test diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..e0d3dd5 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +.vscode +.licenses +.github diff --git a/package.json b/package.json index f6c3cda..001ad22 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "bin": "dist/cli.js", "scripts": { "build": "tsc", - "test": "jest", + "test": "jest --forceExit", "test-watch": "jest --watch", "coverage": "jest --coverage", "update-template": "npx update-template https://github.com/upptime/graphs",