added github workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy Doc.Nuxeo.com | |
on: | |
# schedule: | |
# - cron: '0 5 * * *' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Check Versions | |
id: check-versions | |
run: | | |
RT="git $(git --version)" | |
RT+=" node version $(node --version)" | |
RT+=" npm version $(npm --version)" | |
RT+=" IP $(curl -s ipinfo.io/ip)" | |
echo "RT=${RT}" >> $GITHUB_ENV | |
- name: Remove logs directory | |
run: rm -rf ./logs/* | |
- name: Save runtime versions | |
run: echo "${RT}" > runtime-versions.txt | |
- name: Install dependencies | |
run: npm ci --registry="https://registry.npmjs.org" || npm install --registry="https://registry.npmjs.org" | |
- name: Build | |
run: ALGOLIA_KEY=${{ secrets.NX_TOKEN }} DEBUG_FILE_LEVEL='debug' npm start | |
- name: Generate Nginx Redirects | |
run: bin/redirects-yml2nginx > redirects.txt | |
- name: Create empty redirects_pageid.txt | |
run: echo > redirects_pageid.txt | |
- name: Deploy to Server | |
run: | | |
rsync -Waxvuk --delete site/ root@doc:/opt/www/doc/ | |
rsync redirects.txt root@doc:/etc/nginx/redirects.txt | |
rsync redirects_pageid.txt root@doc:/etc/nginx/redirects_pageid.txt | |
ssh root@doc "service nginx configtest && service nginx restart" | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-artifacts | |
path: | | |
redirects_pageid.* | |
redirects.* | |
*.txt | |
npm-debug.log |