Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(setup): add github actions as CI option #502

Merged
merged 23 commits into from
Dec 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix formatting
  • Loading branch information
jeetiss committed Dec 18, 2019
commit 66b10321291faef41b55535ed5d7efe8de1790bd
128 changes: 64 additions & 64 deletions packages/shipjs/src/step/setup/CI/addGitHubActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,25 @@ function getBaseConfig({ releaseBranch }) {
return ejs.render(
`
name: Ship js trigger
on:
push:
branches:
- <%= releaseBranch %>
jobs:
build:
name: Build
runs-on: Ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
registry-url: 'https://registry.npmjs.org'
- run: git switch <%= releaseBranch %>
- run: npm install
- run: npm run release:trigger
env:
GITHUB_TOKEN: \${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: \${{ secrets.NPM_AUTH_TOKEN }}
on:
push:
branches:
- <%= releaseBranch %>
jobs:
build:
name: Build
runs-on: Ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
registry-url: 'https://registry.npmjs.org'
- run: git switch <%= releaseBranch %>
- run: npm install
- run: npm run release:trigger
env:
GITHUB_TOKEN: \${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: \${{ secrets.NPM_AUTH_TOKEN }}

`,
{ releaseBranch }
Expand All @@ -119,51 +119,51 @@ function getManualPrepareConfig({ baseBranch, gitUserName, gitUserEmail }) {
return ejs.render(
`
name: Ship js Manual Prepare
on:
issue_comment:
types: [created]
jobs:
manual_prepare:
if: |
github.event_name == 'issue_comment' &&
(github.event.comment.author_association == 'member' || github.event.comment.author_association == 'owner') &&
startsWith(github.event.comment.body, '@shipjs prepare')
runs-on: Ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
ref: <%= baseBranch %>
- uses: actions/setup-node@master
- run: npm install
- run: |
git config --global user.email '<%= gitUserEmail %>'
git config --global user.name '<%= gitUserName %>'
- run: npm run release:prepare -- --yes --no-browse
env:
GITHUB_TOKEN: \${{ secrets.GH_TOKEN }}
create_done_comment:
if: success()
needs: manual_prepare
runs-on: Ubuntu-latest
steps:
- uses: actions/github@master
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
with:
args: comment '@\${{ github.actor }} \`shipjs prepare\` done'
create_fail_comment:
if: cancelled() || failure()
needs: manual_prepare
runs-on: Ubuntu-latest
steps:
- uses: actions/github@master
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
with:
args: comment '@\${{ github.actor }} \`shipjs prepare\` fail'
on:
issue_comment:
types: [created]
jobs:
manual_prepare:
if: |
github.event_name == 'issue_comment' &&
(github.event.comment.author_association == 'member' || github.event.comment.author_association == 'owner') &&
startsWith(github.event.comment.body, '@shipjs prepare')
runs-on: Ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
ref: <%= baseBranch %>
- uses: actions/setup-node@master
- run: npm install
- run: |
git config --global user.email '<%= gitUserEmail %>'
git config --global user.name '<%= gitUserName %>'
- run: npm run release:prepare -- --yes --no-browse
env:
GITHUB_TOKEN: \${{ secrets.GH_TOKEN }}

create_done_comment:
if: success()
needs: manual_prepare
runs-on: Ubuntu-latest
steps:
- uses: actions/github@master
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
with:
args: comment '@\${{ github.actor }} \`shipjs prepare\` done'

create_fail_comment:
if: cancelled() || failure()
needs: manual_prepare
runs-on: Ubuntu-latest
steps:
- uses: actions/github@master
env:
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
with:
args: comment '@\${{ github.actor }} \`shipjs prepare\` fail'

`,
{ baseBranch, gitUserName, gitUserEmail }
Expand Down