Skip to content

Run tests and build demo docs #11

Run tests and build demo docs

Run tests and build demo docs #11

name: Run tests and build demo docs
# Run this workflow on pull requests and on demand
on:
pull_request:
workflow_dispatch:
jobs:
run-tests:
name: Run tests against demo wiki
runs-on: ubuntu-latest
# Use our ce-dev Debian base container
container:
image: codeenigma/ce-dev-controller:2.x
volumes:
- ${{ github.workspace }}:/home/controller
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v4
# Configure environment
- name: Prepare Git, GitHub CLI and installed CE tools
run: |
/usr/bin/git config --global user.email "[email protected]"
/usr/bin/git config --global user.name "Code Enigma CI"
/usr/bin/git config --global pull.rebase false
/usr/bin/git config --global --add safe.directory /__w/ce-provision/ce-provision
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) && sudo mkdir -p -m 755 /etc/apt/keyrings && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && sudo apt update && sudo apt install gh -y
/usr/bin/su - ce-dev -c "cd /home/ce-dev/ce-provision && /usr/bin/git pull origin 2.x"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/ce-deploy && /usr/bin/git pull origin 1.x"
- name: Install wiki2pages
run: /usr/bin/su - ce-dev -c "/usr/bin/git clone https://github.com/codeenigma/wikis2pages.git /home/ce-dev/build/wiki2pages"
- name: Set up Ansible and SSH
run: |
mkdir -p /home/ce-dev/ansible/bin/hosts
echo "wikis2pages-hugo ansible_host=127.0.0.1" > /home/ce-dev/ansible/bin/hosts/hosts
echo "StrictHostKeyChecking=no" > /home/ce-dev/.ssh/config
cat /home/ce-dev/.ssh/id_rsa.pub > /home/ce-dev/.ssh/authorized_keys
chown ce-dev:ce-dev /home/ce-dev/.ssh/config
chmod 700 /home/ce-dev/.ssh/config
chown ce-dev:ce-dev /home/ce-dev/.ssh/authorized_keys
chmod 700 /home/ce-dev/.ssh/authorized_keys
/usr/sbin/sshd&
- name: Initialise wiki2pages
run: |
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh init.sh --repo https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/wikis2pages-demo.git --branch master --no-ce-dev"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /home/ce-dev/ansible/bin/ansible-playbook -e 'wiki2pages_build_path=/home/ce-dev/build/wiki2pages' -i /home/ce-dev/ansible/bin/hosts /home/ce-dev/build/wiki2pages/ce-dev/ansible/provision.yml"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh set-current.sh --project wikis2pages-demo-wiki-travis --no-ce-dev"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /home/ce-dev/ansible/bin/ansible-playbook -e 'wiki2pages_build_path=/home/ce-dev/build/wiki2pages launch_hugo_server=false' -i /home/ce-dev/ansible/bin/hosts /home/ce-dev/build/wiki2pages/ce-dev/ansible/deploy.yml"
- name: Run Hugo
run: |
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && hugo"
- name: Publish documentation
run: |
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh /home/ce-dev/build/wiki2pages/.github-actions-push.sh"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages/public/wikis2pages-demo-wiki-travis/docs/wiki && /usr/bin/git remote add ci https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/wikis2pages-demo.git"
/usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages/public/wikis2pages-demo-wiki-travis/docs/wiki && /usr/bin/git push ci master"