From c99bc5c6e818a9e8217d3e888160957c274643cd Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 2 May 2023 17:56:25 +0100 Subject: [PATCH] Updating CI to build and commit the documentation --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ package.json | 3 ++- scripts/updateDocs.sh | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 scripts/updateDocs.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c48c551..1b83a729 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,3 +213,28 @@ jobs: - name: Create Guide & Commit if there are changes run: npm run commit:guides + + update_docs: + runs-on: ubuntu-latest + needs: [test_unit, test_integration] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: checkout ocean.js repo + uses: actions/checkout@v3 + with: + repository: 'oceanprotocol/ocean.js' + path: 'ocean.js' + ref: ${{ github.event.pull_request.head.sha }} + + - name: setup git config + run: | + # setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Create updated docs & commit changes + run: npm run commit:docs diff --git a/package.json b/package.json index d9fdf4fd..8ba37098 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration", "create:guide": "./scripts/createCodeExamples.sh test/integration/CodeExamples.test.ts", "create:guidec2d": "./scripts/createCodeExamples.sh test/integration/ComputeExamples.test.ts", - "commit:guides": "./scripts/commitChanges.sh" + "commit:guides": "./scripts/commitChanges.sh", + "commit:docs": "./scripts/updateDocs.sh" }, "repository": { "type": "git", diff --git a/scripts/updateDocs.sh b/scripts/updateDocs.sh new file mode 100644 index 00000000..11dd85cd --- /dev/null +++ b/scripts/updateDocs.sh @@ -0,0 +1,10 @@ +# Create updated documentation +npm run docs + +# Stage the file, commit and push +git status +git add ./docs +git commit -m "Updating documentation" +branch=${GITHUB_HEAD_REF#refs/heads/} +echo Pushing changes to branch: ${branch} +git push origin HEAD:${branch} --force \ No newline at end of file