Build and Deploy doc.nuxeo.com #234
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: | |
workflow_dispatch: # Manual triggering | |
jobs: | |
documentation_ci: | |
name: Build & Publish documentation to ${{ github.ref_name == 'master' && 'production' || 'development' || 'DevOps-268' }} | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.ref_name == 'master' && 'production' || github.ref_name }} | |
steps: | |
- name: Install SSH key for Bastion | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.DEV_TOOLS_BASTION_PRIVATE_KEY }} | |
name: id_rsa-bastion | |
known_hosts: ${{ secrets.KNOWN_HOSTS_OF_BASTION }} | |
config: ${{ secrets.CONFIG }} | |
- name: Install SSH key of Lethe server | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.DEV_TOOLS_EC2_PRIVATE_KEY }} | |
name: id_rsa-target | |
known_hosts: ${{ secrets.KNOWN_HOSTS_OF_TARGET }} | |
config: ${{ secrets.CONFIG }} | |
- name: Set up SSH for git checkout | |
uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e # v0.8.0 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Checkout code | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- 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 Apache Redirects | |
run: | | |
bin/redirects-yml2nginx > redirects.txt | |
echo > redirects_pageid.txt | |
- name: Deploy to Server | |
run: | | |
rsync -Wxvurk --delete site/ "lethe.nuxeo.com:/opt/www/doc/" | |
rsync redirects.txt "lethe.nuxeo.com:/tmp/redirects.txt" | |
rsync redirects_pageid.txt "lethe.nuxeo.com:/tmp/redirects_pageid.txt" | |
ssh -o StrictHostKeyChecking=no lethe.nuxeo.com "sudo mv /tmp/redirects.txt /etc/apache2/redirects.txt" | |
ssh -o StrictHostKeyChecking=no lethe.nuxeo.com "sudo mv /tmp/redirects_pageid.txt /etc/apache2/redirects_pageid.txt" | |
- name: Apache Config Test and Restart | |
run: | | |
ssh -o StrictHostKeyChecking=no -T lethe.nuxeo.com "apache2ctl configtest && sudo service apache2 restart" | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts | |
path: | | |
redirects_pageid.* | |
redirects.* | |
*.txt | |
npm-debug.log |