diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..38e66d45 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + workflow_dispatch: + inputs: + tag: + description: 'The version tag of the release. This should match version in package.json and start with `v`. For example: `v1.0.0`' + required: true + branch: + description: 'The major version branch to commit to. Default v1.' + default: v1 + required: true + +jobs: + release: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + cache: yarn + - name: Install + run: yarn --prefer-offline --frozen-lockfile --no-progress --non-interactive + - name: Lint + run: yarn lint + - name: Build + run: yarn build + - name: Test + run: yarn test + - name: Commit + uses: endbug/add-and-commit@45a4ede867982d5d85997a82529b1d9dd0328e7f + with: + add: 'build --force' + branch: ${{ github.event.inputs.branch }} + message: 'Add build output' + pull: 'NO-PULL' + push: 'origin ${{ github.event.inputs.branch }} --force' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Tag + uses: ncipollo/release-action@v1 + with: + body: 'TODO: Add CHANGELOG entry' + tag: ${{ github.event.inputs.tag }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..48082f72 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +12 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..25fa6215 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 904eb1ee..f3835334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Apollo Schema Check Action Changelog +## 1.2.1 (December 2, 2021) + +- Improve output for debugging + ## 1.2.0 (August 18, 2021) - Add branch and author information when pushing to Apollo Studio diff --git a/package.json b/package.json index 6b1f3760..5f779bbc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "apollo-schema-check-action", "description": "A GitHub Action to run a schema check and post the results as a comment on a Pull Request", - "version": "1.2.0", + "version": "1.2.1", "author": "Ian Sutherland ", "license": "MIT", "repository": { diff --git a/src/actions.ts b/src/actions.ts index 77684adc..d23dbc41 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -2,7 +2,7 @@ import { inspect } from 'util'; import createDebug from 'debug'; -import { debug as githubDebug } from '@actions/core'; +import { debug as githubDebug, info as githubInfo, error as githubError } from '@actions/core'; const localDebug = createDebug('apollo-schema-check'); @@ -18,4 +18,24 @@ const debug = (...args: any[]): void => { } }; -export { isGitHubActions, debug }; +const info = (...args: any[]): void => { + if (isGitHubActions()) { + for (const arg of args) { + githubInfo(inspect(arg)); + } + } else { + console.log(args); + } +}; + +const error = (...args: any[]): void => { + if (isGitHubActions()) { + for (const arg of args) { + githubError(inspect(arg)); + } + } else { + console.error(args); + } +}; + +export { isGitHubActions, debug, info, error }; diff --git a/src/get-message.ts b/src/get-message.ts index 0983dfef..0fd982c3 100644 --- a/src/get-message.ts +++ b/src/get-message.ts @@ -1,6 +1,6 @@ import execa from 'execa'; -import { debug } from './actions'; +import { debug, info, error as logError } from './actions'; import { getArguments } from './get-arguments'; import { formatMessage } from './format-message'; @@ -18,15 +18,12 @@ const getMessage = async ( arg.startsWith('--key') ? arg.replace(/:[^:]+$/, '***') : arg ); - console.log( - 'Apollo CLI command', - ['npx', 'apollo@2.33.6', 'schema:check', ...redactedArgs].join(' ') - ); + info('Apollo CLI command', ['npx', 'apollo@2.33.6', 'schema:check', ...redactedArgs].join(' ')); try { const output = (await execa('npx', ['apollo@2.33.6', 'schema:check', ...args])).stdout; - console.log(output); + info(output); const message = formatMessage(output, existingComment); @@ -37,11 +34,11 @@ const getMessage = async ( } } catch (error) { if (error.exitCode !== 1) { - console.error(`Apollo CLI error: exit code ${error.exitCode}`, error); + logError(`Apollo CLI error: exit code ${error.exitCode}`, error); throw new Error('Error running Apollo CLI'); } else { - console.log(error.stdout); + info(error.stdout); const message = formatMessage(error.stdout, existingComment);