From b1d31063e4ac09033500bc98d402ce5645ab2e3f Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Thu, 22 Jul 2021 14:47:30 +0200 Subject: [PATCH 01/14] Enabling VNC in ce-dev containers for Chrome output. (#40) --- templates/blank/ce-dev/ansible/provision.yml.j2 | 2 ++ templates/drupal8/ce-dev/ansible/provision.yml.j2 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/templates/blank/ce-dev/ansible/provision.yml.j2 b/templates/blank/ce-dev/ansible/provision.yml.j2 index eb541bc..53bd73a 100644 --- a/templates/blank/ce-dev/ansible/provision.yml.j2 +++ b/templates/blank/ce-dev/ansible/provision.yml.j2 @@ -6,6 +6,8 @@ - project_name: {{ project_name }} - _domain_name: www.{{ project_name }}.local - _env_type: dev + - lhci: + enable_vnc: true tasks: - apt: update_cache: yes diff --git a/templates/drupal8/ce-dev/ansible/provision.yml.j2 b/templates/drupal8/ce-dev/ansible/provision.yml.j2 index 6ad2f59..3279545 100644 --- a/templates/drupal8/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/provision.yml.j2 @@ -42,6 +42,8 @@ _env_type: dev - xdebug: cli: true + - lhci: + enable_vnc: true {% endraw %} tasks: - apt: From a27d3ceec3f3e6223c512c92f47bbe98a2779cfb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Sep 2021 14:34:03 +0200 Subject: [PATCH 02/14] Bump path-parse from 1.0.6 to 1.0.7 (#41) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index a6c9523..d9eeed9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1775,9 +1775,9 @@ path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-type@^4.0.0: version "4.0.0" From 825c69331b309dd8f3192e402e726465b6da8a95 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Thu, 9 Sep 2021 14:35:22 +0200 Subject: [PATCH 03/14] Fixing truthy values pr 1.x (#45) * Adding NET_ADMIN capability to target containers. * Updating all instances of 'yes' to true and 'no' to false in Ansible templates. --- docker-images/controller-ci/provision.yml | 4 ++-- docker-images/controller/provision.yml | 4 ++-- templates/blank/ce-dev/ansible/provision.yml.j2 | 4 ++-- .../blank/ce-dev/ce-dev.compose.prebuilt.yml.j2 | 2 ++ templates/blank/ce-dev/ce-dev.compose.yml.j2 | 4 +++- templates/drupal8/ce-dev/ansible/deploy.yml.j2 | 8 ++++---- .../drupal8/ce-dev/ansible/provision.yml.j2 | 16 ++++++++-------- .../ce-dev/ce-dev.compose.prebuilt.yml.j2 | 2 ++ templates/drupal8/ce-dev/ce-dev.compose.yml.j2 | 2 ++ 9 files changed, 27 insertions(+), 19 deletions(-) diff --git a/docker-images/controller-ci/provision.yml b/docker-images/controller-ci/provision.yml index 114b15f..a385bf8 100644 --- a/docker-images/controller-ci/provision.yml +++ b/docker-images/controller-ci/provision.yml @@ -1,11 +1,11 @@ --- - hosts: localhost - become: yes + become: true vars: - _domain_name: ci.example.com - _ce_provision_build_tmp_dir: /tmp - _ce_provision_data_dir: /tmp - - is_local: yes + - is_local: true - _env_type: utility - ce_provision: own_repository: https://github.com/codeenigma/ce-provision.git diff --git a/docker-images/controller/provision.yml b/docker-images/controller/provision.yml index 8fecf89..fbfde37 100644 --- a/docker-images/controller/provision.yml +++ b/docker-images/controller/provision.yml @@ -1,11 +1,11 @@ --- - hosts: localhost - become: yes + become: true vars: - _domain_name: example.com - _ce_provision_build_tmp_dir: /tmp - _ce_provision_data_dir: /tmp - - is_local: yes + - is_local: true - _env_type: utility - ce_deploy: own_repository: https://github.com/codeenigma/ce-deploy.git diff --git a/templates/blank/ce-dev/ansible/provision.yml.j2 b/templates/blank/ce-dev/ansible/provision.yml.j2 index 53bd73a..e6ddddb 100644 --- a/templates/blank/ce-dev/ansible/provision.yml.j2 +++ b/templates/blank/ce-dev/ansible/provision.yml.j2 @@ -1,7 +1,7 @@ --- - hosts: {{ project_name }}-{{ project_name }} - become: yes + become: true vars: - project_name: {{ project_name }} - _domain_name: www.{{ project_name }}.local @@ -10,7 +10,7 @@ enable_vnc: true tasks: - apt: - update_cache: yes + update_cache: true - import_role: name: _meta/common_base - import_role: diff --git a/templates/blank/ce-dev/ce-dev.compose.prebuilt.yml.j2 b/templates/blank/ce-dev/ce-dev.compose.prebuilt.yml.j2 index eacfef3..8b7f65c 100644 --- a/templates/blank/ce-dev/ce-dev.compose.prebuilt.yml.j2 +++ b/templates/blank/ce-dev/ce-dev.compose.prebuilt.yml.j2 @@ -11,6 +11,8 @@ x-ce_dev: services: {{ project_name }}: image: 'codeenigma/blank-blank:latest' + cap_add: + - NET_ADMIN x-ce_dev: unison: - src: ../ diff --git a/templates/blank/ce-dev/ce-dev.compose.yml.j2 b/templates/blank/ce-dev/ce-dev.compose.yml.j2 index 3dea316..5b7a321 100644 --- a/templates/blank/ce-dev/ce-dev.compose.yml.j2 +++ b/templates/blank/ce-dev/ce-dev.compose.yml.j2 @@ -11,6 +11,8 @@ x-ce_dev: services: {{ project_name }}: image: codeenigma/ce-dev-1.x:latest + cap_add: + - NET_ADMIN x-ce_dev: unison: - src: ../ @@ -20,4 +22,4 @@ services: - linux ignore: - Name vendor - - Name node_modules \ No newline at end of file + - Name node_modules diff --git a/templates/drupal8/ce-dev/ansible/deploy.yml.j2 b/templates/drupal8/ce-dev/ansible/deploy.yml.j2 index 18cf5de..77059d1 100644 --- a/templates/drupal8/ce-dev/ansible/deploy.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/deploy.yml.j2 @@ -27,21 +27,21 @@ config_sync_directory: "config/sync" sanitize_command: "sql-sanitize" # Remove after initial pass, to avoid reinstalling Drupal. - force_install: yes + force_install: true base_url: "https://{{ _domain_name }}" # Composer command to run. - composer: command: install - no_dev: no + no_dev: false working_dir: "{{ deploy_path }}" - apcu_autoloader: no + apcu_autoloader: false pre_tasks: # You can safely remove these steps once you have a working composer.json. - name: Download composer file. get_url: url: https://raw.githubusercontent.com/drupal/recommended-project/8.8.x/composer.json dest: "{{ deploy_path }}/composer.json" - force: no + force: false - name: Install drush. command: cmd: composer require drush/drush diff --git a/templates/drupal8/ce-dev/ansible/provision.yml.j2 b/templates/drupal8/ce-dev/ansible/provision.yml.j2 index 3279545..be1bf99 100644 --- a/templates/drupal8/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/provision.yml.j2 @@ -1,5 +1,5 @@ - hosts: {{ project_name }}-web - become: yes + become: true vars: - _domain_name: www.{{ project_name }}.local - _env_type: dev @@ -22,15 +22,15 @@ cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" handling: "unmanaged" - ratelimitingcrawlers: no - is_default: yes + ratelimitingcrawlers: false + is_default: true servers: - port: 80 - ssl: no - https_redirect: yes + ssl: false + https_redirect: true - port: 443 - ssl: yes - https_redirect: no + ssl: true + https_redirect: false upstreams: [] - php: version: @@ -47,7 +47,7 @@ {% endraw %} tasks: - apt: - update_cache: yes + update_cache: true - import_role: name: _meta/common_base - import_role: diff --git a/templates/drupal8/ce-dev/ce-dev.compose.prebuilt.yml.j2 b/templates/drupal8/ce-dev/ce-dev.compose.prebuilt.yml.j2 index ad86a4f..9902799 100644 --- a/templates/drupal8/ce-dev/ce-dev.compose.prebuilt.yml.j2 +++ b/templates/drupal8/ce-dev/ce-dev.compose.prebuilt.yml.j2 @@ -31,6 +31,8 @@ services: # - Path */sites/*/files volumes: - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN db: image: 'codeenigma/drupal8-db:latest' environment: diff --git a/templates/drupal8/ce-dev/ce-dev.compose.yml.j2 b/templates/drupal8/ce-dev/ce-dev.compose.yml.j2 index c7a7256..61cd6f7 100644 --- a/templates/drupal8/ce-dev/ce-dev.compose.yml.j2 +++ b/templates/drupal8/ce-dev/ce-dev.compose.yml.j2 @@ -31,6 +31,8 @@ services: # - Path */sites/*/files volumes: - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN db: image: mariadb environment: From abdbc53f56796475d43f7358471c90336584c3ab Mon Sep 17 00:00:00 2001 From: Dionisio Date: Tue, 14 Sep 2021 16:05:20 +0200 Subject: [PATCH 04/14] Frontail: Including it by default (#50) Co-authored-by: Dionisio --- templates/blank/ce-dev/ansible/provision.yml.j2 | 4 +++- templates/drupal8/ce-dev/ansible/provision.yml.j2 | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/blank/ce-dev/ansible/provision.yml.j2 b/templates/blank/ce-dev/ansible/provision.yml.j2 index e6ddddb..796799a 100644 --- a/templates/blank/ce-dev/ansible/provision.yml.j2 +++ b/templates/blank/ce-dev/ansible/provision.yml.j2 @@ -14,4 +14,6 @@ - import_role: name: _meta/common_base - import_role: - name: lhci \ No newline at end of file + name: lhci + - import_role: + name: frontail diff --git a/templates/drupal8/ce-dev/ansible/provision.yml.j2 b/templates/drupal8/ce-dev/ansible/provision.yml.j2 index be1bf99..2f75b3f 100644 --- a/templates/drupal8/ce-dev/ansible/provision.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/provision.yml.j2 @@ -60,3 +60,5 @@ name: nginx - import_role: name: lhci + - import_role: + name: frontail From a1ba46517875ed37a82f120742de40420f868a5e Mon Sep 17 00:00:00 2001 From: Dionisio Date: Thu, 23 Sep 2021 15:17:43 +0200 Subject: [PATCH 05/14] Update release files to match with the release (#53) --- RELEASE | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE b/RELEASE index 6e5a721..0f172d5 100644 --- a/RELEASE +++ b/RELEASE @@ -1,2 +1,2 @@ -1.1.14 -Updating the Drupal 8 template due to ce-deploy upstream changes. \ No newline at end of file +1.1.15 +Added frontail to the provision.yml files, for all the templates. diff --git a/package.json b/package.json index c389912..616bdaf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ce-dev", "description": "Local Stack wrapper tool", - "version": "1.1.14", + "version": "1.1.15", "author": " @pm98zz-c", "bin": { "ce-dev": "./bin/run" From 8a1c38556466afe690980902ea082818f27e91a4 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 4 Jan 2022 13:07:35 +0100 Subject: [PATCH 06/14] Release 1.1.16 - ce-provision Galaxy roles. --- RELEASE | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE b/RELEASE index 0f172d5..f2f4eb0 100644 --- a/RELEASE +++ b/RELEASE @@ -1,2 +1,2 @@ -1.1.15 -Added frontail to the provision.yml files, for all the templates. +1.1.16 +Release to repackage ce-provision with latest Ansible Galaxy roles. diff --git a/package.json b/package.json index 616bdaf..953498a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ce-dev", "description": "Local Stack wrapper tool", - "version": "1.1.15", + "version": "1.1.16", "author": " @pm98zz-c", "bin": { "ce-dev": "./bin/run" From 162a9819f2e5dbcdebd997b9f3d8ef6056448759 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 5 Jan 2022 10:06:40 +0100 Subject: [PATCH 07/14] Repackaging due to ce-provision changes. --- RELEASE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE b/RELEASE index f2f4eb0..795c546 100644 --- a/RELEASE +++ b/RELEASE @@ -1,2 +1,2 @@ 1.1.16 -Release to repackage ce-provision with latest Ansible Galaxy roles. +Release to repackage ce-provision with latest Ansible Galaxy roles and other ce-provision changes. From b143e4d7ea7812ffa6e3fdd43e57b9314c2b414b Mon Sep 17 00:00:00 2001 From: nfawbert <62660788+nfawbert@users.noreply.github.com> Date: Thu, 13 Jan 2022 10:59:25 +0000 Subject: [PATCH 08/14] Statically set drush version 10 for drupal8 (#60) --- templates/drupal8/ce-dev/ansible/deploy.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/drupal8/ce-dev/ansible/deploy.yml.j2 b/templates/drupal8/ce-dev/ansible/deploy.yml.j2 index 77059d1..b187628 100644 --- a/templates/drupal8/ce-dev/ansible/deploy.yml.j2 +++ b/templates/drupal8/ce-dev/ansible/deploy.yml.j2 @@ -44,7 +44,7 @@ force: false - name: Install drush. command: - cmd: composer require drush/drush + cmd: composer require drush/drush "^10.6.2" chdir: "{{ deploy_path }}" roles: - _init # Sets some variables the deploy scripts rely on. From 42ea5e31272808bc78df64fc7e9043f7a9a5513d Mon Sep 17 00:00:00 2001 From: Philip Norton Date: Fri, 14 Jan 2022 13:05:32 +0000 Subject: [PATCH 09/14] Updated troubleshooting tips. (#61) Included the solution to the cgroup issue. --- docs/Troubleshooting.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 38291c2..c35541a 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -5,3 +5,22 @@ Changes in files on your host not being reflected in the container(s) can have a If your files are not updating you should check the [maximum permitted `inotify` watchers](install#inotify-watcher-limit). ### Text editor The way some editors behave on save means the inumber of the file does not change, so unison does not pick up a difference and the files in your containers do not update. Notable culprits are `vim` and `Atom`. In both cases there are fixes - for example the `local-history` plugin for `Atom` forces it to behave as we need. If you have mysterious issues with files not changing in your containers and it isn't the `inotify` watcher limit above, check how your editor behaves. + +## Cgroup Issues +If your ce-dev is failing to even start the controller then you'll see a response that looks like this. +``` +Creating ce_dev_controller ... done +Ensure user UID match those on the host... +Ensure user UID match those on the host... ! + Error: Command failed: sudo docker exec ce_dev_controller /bin/sh /opt/ce-dev-ownership.sh 1000 1000 +``` +There will be very little in the way of logs or errors from this. Just an indication of a problem. + +It turns out that if you are using Ubuntu 21.10 (or POP! OS) then it will be using kernelstub and not grub. This might create incompatabilities between docker and cgroup version 2. To fix this you need to run the following commands. + +``` +sudo kernelstub -a "systemd.unified_cgroup_hierarchy=0" +sudo update-initramfs -c -k all +``` + +They will take a while to run (about 10 minutes), but once complete reboot your machine and delete any created containers that velong to the ce_dev image. When you rebuild the ce-dev controller (by running any command) it should create fine. From eddd62821f2cb8361dc809a7ea1cbe8e922ce8f7 Mon Sep 17 00:00:00 2001 From: nfawbert <62660788+nfawbert@users.noreply.github.com> Date: Mon, 17 Jan 2022 09:36:41 +0000 Subject: [PATCH 10/14] update ce-dev docs (#62) --- docs/GettingStarted.md | 2 +- docs/Troubleshooting.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index dc2b2f7..7e7caf8 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -69,4 +69,4 @@ That should open https://www.hello.local in a new browser's tab, with a fresh Dr ``` ce-dev shell ``` -Will open a shell in the 'web' container. You can then `cd ~/deploy/live.local` and run a `drush uli` to grab a login link. +Will open a shell in the 'web' container. You can then `cd ~/deploy/live.local` and run a `vendor/drush/drush/drush uli` to grab a login link. diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index c35541a..147f0b4 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -24,3 +24,23 @@ sudo update-initramfs -c -k all ``` They will take a while to run (about 10 minutes), but once complete reboot your machine and delete any created containers that velong to the ce_dev image. When you rebuild the ce-dev controller (by running any command) it should create fine. + +## VM Networking issue +If you're running ce-dev from within a Virtual Machine (eg. KVM/qemu), Docker container network ports are only 'exposed' to the hypervisor (ie the VM), and are not published for external access. +In order to access sites/files deployed by ce-dev, the ports needs to be published so that the Docker containers can be accessed from your workstation. +After running ```ce-dev init``` (before ```ce-dev start```) edit the ~/project/ce-dev/docker-compose.yml + +Replace; +``` + expose: + - 443 + - 80 + - '22' +``` +With; +``` + ports: + - '443:443' + - '80:80' + - '22' +``` From fc5e73db76b0282639c75b326f1e94dd84af4205 Mon Sep 17 00:00:00 2001 From: Nick Fawbert Date: Mon, 17 Jan 2022 11:55:46 +0000 Subject: [PATCH 11/14] repackage ce-dev to force d8 compatible drush version in template --- RELEASE | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE b/RELEASE index 795c546..b1aff8c 100644 --- a/RELEASE +++ b/RELEASE @@ -1,2 +1,2 @@ -1.1.16 -Release to repackage ce-provision with latest Ansible Galaxy roles and other ce-provision changes. +1.1.17 +Release to repackage ce-dev to force d8 compatible drush version. diff --git a/package.json b/package.json index 953498a..0546524 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ce-dev", "description": "Local Stack wrapper tool", - "version": "1.1.16", + "version": "1.1.17", "author": " @pm98zz-c", "bin": { "ce-dev": "./bin/run" From 1ba4d00b7a2fa1b7f3ecc8460ef9221856ef37e5 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Mon, 17 Jan 2022 13:36:41 +0100 Subject: [PATCH 12/14] Adding CI to build and publish ce-dev docs automatically. --- .github/workflows/ce-dev-publish-docs.yml | 50 +++++++++++++++++++ .github/workflows/ce-provision-build-docs.yml | 48 ++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 .github/workflows/ce-dev-publish-docs.yml create mode 100644 .github/workflows/ce-provision-build-docs.yml diff --git a/.github/workflows/ce-dev-publish-docs.yml b/.github/workflows/ce-dev-publish-docs.yml new file mode 100644 index 0000000..882fd8b --- /dev/null +++ b/.github/workflows/ce-dev-publish-docs.yml @@ -0,0 +1,50 @@ +name: Publish docs + +# Run this workflow on push to 1.x (e.g. on merge of PR to 1.x) +on: + push: + branches: + - 1.x + +jobs: + # Set the job key. The key is displayed as the job name + # when a job name is not provided + run-tests: + # Name the Job + name: Publish documentation + # Set the type of machine to run on + runs-on: ubuntu-20.04 + + steps: + # Configures global Git variables for committing + - name: Configure Git + run: | + git config --global user.email "sysadm@codeenigma.com" + git config --global user.name "Code Enigma CI" + # Installs the ce-dev stack + - name: Install ce-dev + run: | + cd /tmp + wget https://golang.org/dl/go1.15.8.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.15.8.linux-amd64.tar.gz + export PATH=$PATH:/usr/local/go/bin + git clone https://github.com/FiloSottile/mkcert && cd mkcert + go build -ldflags "-X main.Version=$(git describe --tags)" + sudo mv ./mkcert /usr/local/bin && cd ../ + sudo chmod +x /usr/local/bin/mkcert + rm -Rf mkcert + curl -sL https://raw.githubusercontent.com/codeenigma/ce-dev/1.x/install.sh | /bin/sh -s -- linux + # Uses the ce-dev stack to run Hugo to format and deploy the docs + - name: Publish documentation + run: | + cd + git clone https://github.com/codeenigma/wikis2pages.git + cd wikis2pages + /bin/bash init.sh https://${{ secrets.GITHUB_TOKEN }}@github.com/codeenigma/ce-dev.git 1.x + /bin/sh set-current.sh ce-dev-1.x + docker exec --user ce-dev --workdir /home/ce-dev/deploy/live.local wikis2pages-hugo hugo + /bin/sh .github-actions-push.sh + cd /home/runner/wikis2pages/public/ce-dev-1.x + git remote add ci https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/ce-dev-docs.git + git push ci master + shell: bash diff --git a/.github/workflows/ce-provision-build-docs.yml b/.github/workflows/ce-provision-build-docs.yml new file mode 100644 index 0000000..bbd1c64 --- /dev/null +++ b/.github/workflows/ce-provision-build-docs.yml @@ -0,0 +1,48 @@ +name: Build docs + +# Run this workflow every time a new commit pushed to your repository +on: pull_request + +jobs: + # Set the job key. The key is displayed as the job name + # when a job name is not provided + build-docs: + # Name the Job + name: Build the documentation + # Set the type of machine to run on + runs-on: ubuntu-20.04 + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout code + if: ${{ github.event.pull_request.head.ref != 'documentation' }} + uses: actions/checkout@v2 + + # Configures global Git variables for committing + - name: Configure Git + run: | + git config --global user.email "sysadm@codeenigma.com" + git config --global user.name "Code Enigma CI" + + # Builds the docs + - name: Build documentation + if: ${{ github.event.pull_request.head.ref != 'documentation' }} + run: | + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git fetch + git checkout documentation + contribute/toc.sh + git add docs + git diff --quiet && git diff --staged --quiet || git commit -am 'GitHub Actions - Rebuilt documentation.' && git push origin documentation + shell: bash + + # Create docs pull request + - name: Create a documentation pull request + if: ${{ github.event.pull_request.head.ref != 'documentation' && github.event.pull_request.base.ref == '1.x' }} + uses: devops-infra/action-pull-request@v0.4.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: documentation + target_branch: ${{ github.event.pull_request.base.ref }} + title: Documentation update. + body: "**Automated pull request** created by GitHub Actions because of a documentation update." From c002862fddd4ef71ef54e0a1df06a7fda284342a Mon Sep 17 00:00:00 2001 From: gregharvey Date: Mon, 17 Jan 2022 13:41:07 +0100 Subject: [PATCH 13/14] ce-dev didn't have the toc.sh docs builder script. --- contribute/toc.sh | 140 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 contribute/toc.sh diff --git a/contribute/toc.sh b/contribute/toc.sh new file mode 100755 index 0000000..face006 --- /dev/null +++ b/contribute/toc.sh @@ -0,0 +1,140 @@ +#!/bin/sh +# shellcheck disable=SC2094 +# shellcheck disable=SC2129 +IFS=$(printf '\n\t') +set -e +OWN_DIR=$(dirname "$0") +cd "$OWN_DIR" || exit 1 +OWN_DIR=$(git rev-parse --show-toplevel) +cd "$OWN_DIR" || exit 1 +OWN_DIR=$(pwd -P) + +# @param +# $1 string filepath +cp_role_page(){ + RELATIVE=$(realpath --relative-to="$OWN_DIR" "$(dirname "$1")") + if [ ! -d "$OWN_DIR/docs/$RELATIVE" ]; then + mkdir -p "$OWN_DIR/docs/$RELATIVE" + fi + cp "$1" "$OWN_DIR/docs/$RELATIVE.md" +} + +# @param +# $1 string folder +cp_single_page(){ + if [ ! -d "$OWN_DIR/docs/$1" ]; then + mkdir "$OWN_DIR/docs/$1" + fi + cp "$OWN_DIR/$1/README.md" "$OWN_DIR/docs/$1.md" +} + +# @param +# $1 (string) filename +parse_role_variables(){ + TMP_MD=$(mktemp) + WRITE=1 + # Ensure we have a trailing line. + echo "" >> "$1" + while read -r LINE; do + case $LINE in + '') + echo "$LINE" >> "$TMP_MD" + generate_role_variables "$1" + WRITE=0 + ;; + '') + echo "$LINE" >> "$TMP_MD" + WRITE=1 + ;; + '') + echo "$LINE" >> "$TMP_MD" + WRITE=0 + ;; + '') + echo "$LINE" >> "$TMP_MD" + WRITE=1 + ;; + *) + if [ $WRITE = 1 ]; then + echo "$LINE" >> "$TMP_MD" + fi + ;; + esac + done < "$1" + printf '%s\n' "$(cat "$TMP_MD")" > "$1" + rm "$TMP_MD" +} + +# @param +# $1 (string) filename +generate_role_variables(){ + VAR_FILE="$(dirname "$1")/defaults/main.yml" + if [ -f "$VAR_FILE" ]; then + echo "## Default variables" >> "$TMP_MD" + echo '```yaml' >> "$TMP_MD" + cat "$VAR_FILE" >> "$TMP_MD" + echo "" >> "$TMP_MD" + echo '```' >> "$TMP_MD" + echo "" >> "$TMP_MD" + fi +} + +generate_roles_toc(){ + TMP_SIDEBAR=$(mktemp) + WRITE="true" + while read -r LINE; do + case $LINE in + " - [Roles](roles)") + echo "$LINE" >> "$TMP_SIDEBAR" + parse_roles_toc roles 2 + WRITE="false" + ;; + " -"*) + WRITE="true" + echo "$LINE" >> "$TMP_SIDEBAR" + ;; + *) + if [ "$WRITE" = "true" ]; then + echo "$LINE" >> "$TMP_SIDEBAR" + fi + ;; + esac + done < "$OWN_DIR/docs/_Sidebar.md" + mv "$TMP_SIDEBAR" "$OWN_DIR/docs/_Sidebar.md" +} + +parse_roles_toc(){ + ROLES=$(find "$OWN_DIR/$1" -mindepth 2 -maxdepth 2 -name "README.md" | sort) + for ROLE in $ROLES; do + WRITE="true" + INDENT=$(printf %$(($2 * 2))s) + RELATIVE=$(realpath --relative-to="$OWN_DIR" "$(dirname "$ROLE")") + while read -r LINE; do + case $LINE in + "# "*) + if [ "$WRITE" = "true" ]; then + TITLE=$(echo "$LINE" | cut -c 3-) + echo "$INDENT"" - [$TITLE](/$RELATIVE)" >> "$TMP_SIDEBAR" + WRITE="false" + fi + ;; + esac + done < "$ROLE" + parse_roles_toc "$RELATIVE" $(($2 + 1)) + done +} + +rm -rf "$OWN_DIR/docs/roles" +ROLE_PAGES=$(find "$OWN_DIR/roles" -name "README.md") +for ROLE_PAGE in $ROLE_PAGES; do + parse_role_variables "$ROLE_PAGE" +done +for ROLE_PAGE in $ROLE_PAGES; do + cp_role_page "$ROLE_PAGE" +done +generate_roles_toc + + +cp_single_page install +cp_single_page contribute +cp_single_page scripts \ No newline at end of file From 398cf8c85e6a0d66873ec2a97c21893378d26364 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Mon, 17 Jan 2022 15:59:13 +0100 Subject: [PATCH 14/14] Removing doc push step from build job, it has its own job now. --- .github/workflows/ce-dev-build.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/ce-dev-build.yml b/.github/workflows/ce-dev-build.yml index 946aa33..d9c3601 100644 --- a/.github/workflows/ce-dev-build.yml +++ b/.github/workflows/ce-dev-build.yml @@ -51,16 +51,3 @@ jobs: body_path: RELEASE env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build and publish docs - run: | - cd - curl -sL https://raw.githubusercontent.com/codeenigma/ce-dev/1.x/install.sh | /bin/sh -s -- linux - git clone https://github.com/codeenigma/wikis2pages.git - cd wikis2pages - /bin/sh init.sh https://${{ secrets.GITHUB_TOKEN }}@github.com/codeenigma/ce-dev.git 1.x - /bin/sh set-current.sh ce-dev-travis - docker exec --user ce-dev --workdir /home/ce-dev/deploy/live.local wikis2pages-hugo hugo - /bin/sh .github-actions-push.sh - cd /home/runner/wikis2pages/public/ce-dev-travis - git remote add ci https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/ce-dev-docs.git - git push ci master