diff --git a/.github/scripts/pushdocs.sh b/.github/scripts/pushdocs.sh new file mode 100644 index 0000000..fedb1ee --- /dev/null +++ b/.github/scripts/pushdocs.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +PAGES_USER="ibm-security-verify" +PAGES_REPO="ibm-security-verify.github.io" +PAGES_BRANCH="master" +DESTINATION_ROOT="${GITHUB_WORKSPACE}/docs" +SOURCE_ROOT="${GITHUB_WORKSPACE}/monorepo" + +# generate privacy sdk docs +MODULE=privacy +DOC_TARGET_FOLDER="${DESTINATION_ROOT}/javascript/${MODULE}/docs" +mkdir -p "${DOC_TARGET_FOLDER}" +cd ${SOURCE_ROOT}/sdk/${MODULE} && npm i && npm run docs && cd - +cp -R ${SOURCE_ROOT}/sdk/${MODULE}/docs/. ${DOC_TARGET_FOLDER}/ + +# configure and push to github docs repo +cd ${SOURCE_ROOT} +MESSAGE=`git log --format=%B -n 1` +cd ${DESTINATION_ROOT} +# thanks to https://stackoverflow.com/a/64271581/5099773 +git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | \ + xargs -L1 git config --unset-all +git config user.email "raghu4u449@gmail.com" +git config user.name "rramk" +git add -A +git diff-index --quiet HEAD || git commit -m "${MESSAGE}" +git push -u https://${PAGES_USER}:${GH_PAGES_TOKEN}@github.com/${PAGES_USER}/${PAGES_REPO} diff --git a/.github/workflows/publishpackage.yml b/.github/workflows/publishpackage.yml new file mode 100644 index 0000000..9e7fc9a --- /dev/null +++ b/.github/workflows/publishpackage.yml @@ -0,0 +1,30 @@ +name: Publish packages to NPM + +on: + release: + types: [created] + push: + tags: + - '**' +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + # Setup .npmrc file to publish + - uses: actions/setup-node@v2 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - name: Publish package to NPM + run: | + TAG=${GITHUB_REF:10} + MODULE=`echo "$TAG" | sed -e 's/@ibm-security-verify\/\([a-zA-Z].*\)@.*$/\1/'` + # This step would fail if module is not a valid sdk + cd ${GITHUB_WORKSPACE}/sdk/${MODULE} + npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pushdocs.yml b/.github/workflows/pushdocs.yml new file mode 100644 index 0000000..072d7dc --- /dev/null +++ b/.github/workflows/pushdocs.yml @@ -0,0 +1,40 @@ +name: Push documentation to github pages repo + +env: + GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }} + +# Trigger the workflow on push to main or when a github release is created +on: + push: + branches: + - main + tags: + - '**' + release: + types: [created] + +jobs: + pushdocs: + name: Push SDK documentation + runs-on: ubuntu-latest + + steps: + - name: Checkout sdk monorepo + uses: actions/checkout@v2 + with: + path: monorepo + + - name: Checkout github docs repo + uses: actions/checkout@v2 + with: + repository: ibm-security-verify/ibm-security-verify.github.io + path: docs + + - name: Install npm + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Push docs + run: ${{ github.workspace }}/monorepo/.github/scripts/pushdocs.sh + shell: bash