Skip to content

Commit

Permalink
chore(ci): refactor release and dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Mar 15, 2021
1 parent aec56a7 commit 4a6f29e
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 179 deletions.
27 changes: 3 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: 'build-test'
on:
push:
push:
branches:
- main
- develop
tags:
- '*'
pull_request:
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target for security implications.
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
Expand All @@ -23,7 +21,6 @@ jobs:
- name: Get info
id: info
run: |
echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
echo ::set-output name=repo_name::$(echo $GITHUB_REPOSITORY| cut -d / -f 2)
echo ::set-output name=repo_owner::$(echo $GITHUB_REPOSITORY| cut -d / -f 1)
Expand Down Expand Up @@ -53,21 +50,3 @@ jobs:
args: >
-Dsonar.organization=${{ steps.info.outputs.repo_owner }}
-Dsonar.projectKey=${{ steps.info.outputs.repo_name }}
- name: Get installation token
if: github.event_name != 'pull_request' && contains('refs/heads/main', github.ref) && matrix.node-version == 14
uses: npalm/[email protected]
id: app-token
with:
appId: ${{ secrets.APP_ID }}
appPrivateKeyBase64: ${{ secrets.APP_PRIVATE_KEY_BASE64 }}
appInstallationType: repo
appInstallationValue: ${{ github.repository }}

- name: Release
if: github.event_name != 'pull_request' && contains('refs/heads/main', github.ref) && matrix.node-version == 14
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn release --repositoryUrl https://x-access-token:[email protected]/$GITHUB_REPOSITORY.git
4 changes: 2 additions & 2 deletions .github/workflows/dependabot-merge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'dependabot-auto-merge'
on:
pull_request:
pull_request_target:

jobs:
build:
Expand All @@ -11,5 +11,5 @@ jobs:
- name: Auto merge dependabot
uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
github-token: ${{ secrets.TOKEN_DEPENDABOT }}
github-token: ${{ secrets.GITHUB_TOKEN }}

44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Release'
on:
workflow_dispatch:
inputs:
options:
description: "Extra options for running a release, e.g. -d for a dry run"
default: ''
required: false

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false

- uses: actions/setup-node@v2
with:
node-version: 14

- name: Install dependencies
run: yarn

- name: Run checks
run: yarn run test && yarn lint && yarn run build

- name: Get installation token
uses: npalm/[email protected]
id: app-token
with:
appId: ${{ secrets.APP_ID }}
appPrivateKeyBase64: ${{ secrets.APP_PRIVATE_KEY_BASE64 }}
appInstallationType: repo
appInstallationValue: ${{ github.repository }}

- name: Release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn release ${{ github.event.inputs.options }} --repositoryUrl https://x-access-token:[email protected]/$GITHUB_REPOSITORY.git
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"test": "yarn run test-default && yarn run test-cli",
"test-default": "jest --testPathIgnorePatterns=__tests__/cli.test.ts --collect-coverage --coverage",
"test-cli": "nyc jest --silent --testMatch=**/cli*test.ts && nyc report --reporter=lcov --reporter=html --report-dir=./coverage_nyc",
"all": "npm run build && npm run format && npm run lint && npm test",
"test-default": "jest --testTimeout=10000 --testPathIgnorePatterns=__tests__/cli.test.ts --collect-coverage --coverage",
"test-cli": "nyc jest --testTimeout=10000 --silent --testMatch=**/cli*test.ts && nyc report --reporter=lcov --reporter=html --report-dir=./coverage_nyc",
"all": "yarn run build && yarn run format && yarn run lint && yarn test",
"watch": "ts-node-dev --respawn --exit-child",
"dev": "ts-node",
"release": "semantic-release"
Expand Down
Loading

0 comments on commit 4a6f29e

Please sign in to comment.