Skip to content

Commit 3bba6ec

Browse files
authored
* ci: add github actions new workflows * ci: fix [skip ci] try to skip travis run * ci: new fix * ci: try fix * ci: try fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: PR actions changes
1 parent 04f3d31 commit 3bba6ec

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

.github/workflows/build-test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
5+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
6+
7+
name: Build and Test
8+
9+
on:
10+
push:
11+
branches: [ '**' ]
12+
pull_request:
13+
branches: [ master ]
14+
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
jobs:
19+
build_test:
20+
name: Build and Test on Node ${{ matrix.node-version }} and ${{ matrix.os }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
node-version: ['10.x', '12.x']
25+
os: [ubuntu-latest]
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Set up Node
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
- name: Execute Node unit tests
34+
run: |
35+
npm ci
36+
npm run build --if-present
37+
npm run test-unit-travis
38+
npm run check-packages
39+
scripts/typedoc/generate_typedoc.sh
40+
- name: Execute Node code coverage
41+
if: matrix.node-version == '10.x'
42+
run: npm run report-coverage
43+
- name: Publish js docs
44+
if: matrix.node-version == '10.x'
45+
env:
46+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
47+
GHA_REPO_SLUG: ${{ github.repository }}
48+
GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part
49+
GHA_PULL_REQUEST: ${{ github.event.number }}
50+
GHA_BUILD_NUMBER: ${{ github.run_number }}
51+
GHA_JOB_NUMBER: ${{ github.job_number }}
52+
GHA_COMMIT: ${{ github.sha }}
53+
# GHA_TAG: ${{ github.event.release.tag_name }}
54+
run: scripts/jsdoc/publish_gha.sh

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support documentation.
4+
# This workflow will download a prebuilt Node version, install dependencies, build and deploy/publish a new release
5+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
6+
7+
name: Deploy and Publish
8+
9+
on:
10+
workflow_run:
11+
workflows: ["Build and Test"]
12+
branches: [ master ]
13+
types:
14+
- completed
15+
16+
# Allows you to run this workflow manually from the Action tab
17+
workflow_dispatch:
18+
19+
jobs:
20+
deploy:
21+
if: "!contains(github.event.head_commit.message, 'skip ci')"
22+
name: Deploy and Publish
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
with:
28+
persist-credentials: false
29+
- name: Set up Node
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: 12
33+
- name: Install Semantic Release dependencies
34+
run: |
35+
sudo apt-get install bumpversion
36+
npm install -g semantic-release
37+
npm install -g @semantic-release/changelog
38+
npm install -g @semantic-release/exec
39+
npm install -g @semantic-release/git
40+
npm install -g @semantic-release/github
41+
npm install -g @semantic-release/commit-analyzer
42+
npm install -g @semantic-release/release-notes-generator
43+
- name: Publish to Git Releases and Tags
44+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
47+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
run: npx semantic-release --dry-run
49+

scripts/jsdoc/publish_gha.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# This is the Github Actions version based on the travis version
4+
5+
if [ "$GHA_REPO_SLUG" == "watson-developer-cloud/node-sdk" ] && [ "$GHA_PULL_REQUEST" == "" ] && [ "$GHA_BRANCH" ]; then
6+
7+
echo "Publishing JSDoc..."
8+
9+
export GHA_BRANCH=${GHA_BRANCH##*/} # Get the last part for true branch name - "refs/heads/9260_gha"
10+
11+
git config --global user.email "[email protected]"
12+
git config --global user.name "watdevex"
13+
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/node-sdk gh-pages > /dev/null
14+
15+
pushd gh-pages
16+
# make a directory named after the branch/tag for the current build, replacing the previous one if present
17+
# on tagged builds, $GHA_BRANCH is the tag (e.g. v1.2.3), otherwise it's the branch name (e.g. master)
18+
rm -rf $GHA_BRANCH
19+
mkdir $GHA_BRANCH
20+
cp -Rf ../doc/. ./$GHA_BRANCH
21+
22+
# update the latest/ symlink
23+
# on tagged builds, $GHA_TAG is set to the tag, but it's blank on regular builds, unlike $GHA_BRANCH
24+
if [ $GHA_TAG ]; then
25+
rm latest
26+
ln -s ./$GHA_TAG latest
27+
fi
28+
29+
# todo: automatically delete folders that don't have a matching git branch
30+
31+
echo "tags:"
32+
# sorted list of tags, newest first:
33+
git tag --sort -version:refname
34+
35+
echo ""
36+
echo "branches:"
37+
# list branches
38+
git branch --remote | grep --invert-match gh-pages | sed -e 's/.*origin\/\(.*\)/\1/' | uniq
39+
40+
# generate an incdex file listing all of the versions
41+
../scripts/jsdoc/generate_index_html.sh > index.html
42+
43+
# add all changes to git, including deleted files
44+
git add -f -A .
45+
git commit -m "Doc for $GHA_BRANCH ($GHA_COMMIT)"
46+
git push -fq origin gh-pages > /dev/null
47+
48+
popd
49+
50+
echo -e "Published Doc for $GHA_BRANCH to gh-pages.\n"
51+
52+
else
53+
54+
echo -e "Not publishing docs for build $GHA_BUILD_NUMBER ($GHA_JOB_NUMBER) on branch $GHA_BRANCH of repo $GHA_REPO_SLUG"
55+
56+
fi

0 commit comments

Comments
 (0)