From 9978954c23ddee981c4d0babe686b043256b1048 Mon Sep 17 00:00:00 2001 From: sushil chaudhary Date: Fri, 2 Feb 2024 17:28:16 +0530 Subject: [PATCH] Devops 182 (#122) * added github pipeline * added github workflow * added github workflow * added github workflow * fix PR comments * add secretes * add ssh action * syntax correction * updated workflow * PR comments * correct branch * add key file * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Alex Chapellon * PR comment * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Alex Chapellon * add missing ssh argument * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> * Add dependabot file * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> * Update .github/workflows/doc.nuxeo.com.yml Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> * testing with master-nx-assets branch * testing with master-nx-assets branch --------- Co-authored-by: Alex Chapellon Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> --- .github/dependabot.yml | 6 +++ .github/workflows/doc.nuxeo.com.yml | 70 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/doc.nuxeo.com.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..8ac6b8c4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/doc.nuxeo.com.yml b/.github/workflows/doc.nuxeo.com.yml new file mode 100644 index 00000000..2540573b --- /dev/null +++ b/.github/workflows/doc.nuxeo.com.yml @@ -0,0 +1,70 @@ +name: Build and Deploy doc.nuxeo.com + +on: + push: + branches: + - master + - development + - master-nx-assets + +jobs: + documentation_ci: + name: Build & Publish documentation to ${{ github.ref_name == 'master' && 'production' || 'development' }} + runs-on: doc + environment: + name: ${{ github.ref_name == 'master' && 'production' || 'development' }} + steps: + - name: Set up SSH + uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e # v0.8.0 + with: + ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} + + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up Node.js + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + with: + node-version: '14' + + - name: Check Versions and Save to File + run: | + echo "git $(git --version)" > runtime-versions.txt + echo "node version $(node --version)" >> runtime-versions.txt + echo "npm version $(npm --version)" >> runtime-versions.txt + echo "IP $(curl -s ipinfo.io/ip)" >> runtime-versions.txt + + - name: Install dependencies + run: npm ci --registry="https://registry.npmjs.org" || npm install --registry="https://registry.npmjs.org" + + - name: Build + env: + ALGOLIA_KEY: ${{ secrets.NX_TOKEN }} + DEBUG_FILE_LEVEL: debug + run: npm start + + - name: Generate Nginx Redirects + run: | + bin/redirects-yml2nginx > redirects.txt + echo > redirects_pageid.txt + + - name: Deploy to Server + run: | + rsync -Wxvuk --delete site/ "${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/opt/www/doc/" + rsync redirects.txt "${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/etc/nginx/redirects.txt" + rsync redirects_pageid.txt ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/etc/nginx/redirects_pageid.txt + + - name: Nginx Config Test and Restart + run: | + ssh "${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}" \ + "service nginx configtest && service nginx restart" + + - name: Archive Artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: | + redirects_pageid.* + redirects.* + *.txt + npm-debug.log \ No newline at end of file