Update .github/workflows/doc.nuxeo.com.yml #6
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: | ||
push: | ||
branches: | ||
- master | ||
- development | ||
jobs: | ||
documentation_ci: | ||
name: Build & Publish documentation to ${{ github.ref_name == 'master' && 'production' || github.ref_name }} | ||
runs-on: doc | ||
environment: | ||
name: ${{ github.ref == 'refs/heads/master' && 'production' || github.ref == 'refs/heads/development' && 'development' || '' }} | ||
steps: | ||
- name: Set up SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '14' | ||
- name: Set up SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} | ||
- 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 | ||
run: ALGOLIA_KEY=${{ secrets.NX_TOKEN }} DEBUG_FILE_LEVEL='debug' npm start | ||
- name: Generate Nginx Redirects | ||
run: | | ||
bin/redirects-yml2nginx > redirects.txt | ||
echo > redirects_pageid.txt | ||
- name: Deploy to Server | ||
run: | | ||
rsync -Wxvuk --delete -e "ssh -i ${{ secrets.SERVER_SSH_PRIVATE_KEY }}" site/ "${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/opt/www/doc/" | ||
rsync -e "ssh -i ${{ secrets.SERVER_SSH_PRIVATE_KEY }}" redirects.txt "${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/etc/nginx/redirects.txt" | ||
rsync -e "ssh -i ${{ secrets.SERVER_SSH_PRIVATE_KEY }}" redirects_pageid.txt ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }}:/etc/nginx/redirects_pageid.txt | ||
- name: Nginx Config Test and Restart | ||
run: | | ||
ssh -i "${{ secrets.SERVER_SSH_PRIVATE_KEY }}" \ | ||
"${{ 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 |