From 6b81d0ec18b1d80d281a11cbf6cda06af09ebdd7 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Sat, 13 Jan 2024 12:03:38 +1100 Subject: [PATCH] [#1137] Moved docs publishing to GHA. --- .circleci/config.yml | 47 ---------------- .drevops/docs/.utils/composer.json | 1 + .drevops/docs/.utils/composer.lock | 6 ++- .drevops/docs/.utils/publish.sh | 2 + .../installer/src/Command/InstallCommand.php | 3 ++ .drevops/tests/bats/_helper.bash | 1 + .github/workflows/drevops-publish-docs.yml | 53 +++++++++++++++++++ 7 files changed, 64 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/drevops-publish-docs.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d9da681c..d4d60c64a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -616,40 +616,6 @@ jobs: # the main workflow are separated from this one. DREVOPS_CI_DB_CACHE_BRANCH: drevops-dev-didi-ii - #----------------------------------------------------------------------------- - # Publish docs to docs.drevops.com - # @todo Move this to GitHub Actions. - #----------------------------------------------------------------------------- - drevops-dev-deploy-docs: - <<: *runner_config - steps: - - checkout - - *step_process_codebase - - *step_setup_remote_docker - - *step_setup_docker_network - - add_ssh_keys: - fingerprints: - - "22:fe:71:f4:65:8d:cb:81:9c:31:09:4e:03:0b:33:b7" - - run: - name: Build and test docs - command: | - cd .drevops/docs - ahoy build - ahoy lint - ahoy test - - run: - name: Publish docs - command: | - cd .drevops/docs - export DOCS_PUBLISH_REMOTE_URL=https://github.com/drevops/drevops_docs.git - export DOCS_PUBLISH_SRC_TAG=${CIRCLE_TAG:-} - export DOCS_PUBLISH_SRC_BRANCH=${CIRCLE_BRANCH:-} - export DOCS_PUBLISH_SSH_FINGERPRINT="22:fe:71:f4:65:8d:cb:81:9c:31:09:4e:03:0b:33:b7" - export DOCS_PUBLISH_CANARY_BRANCH="develop" - export DOCS_PUBLISH_COMMIT_MESSAGE="Automatically pushed from drevops/drevops" - export DOCS_PUBLISH_GIT_EMAIL="deployer@drevops.com" - ./.utils/publish.sh - #----------------------------------------------------------------------------- # Publish installer to install.drevops.com # @todo Move this to GitHub Actions. @@ -810,19 +776,6 @@ workflows: tags: only: /^[0-9]+(\.[0-9]+)+(-rc[0-9]+)?$/ - # Build and publish DrevOps docs. - - drevops-dev-deploy-docs: - requires: - - build - - drevops-dev-test - - drevops-dev-test-workflow - filters: - branches: - # 'main' or any branch with 'docs' in the name. - only: /^main$|^develop$|.*docs.*/ - tags: - only: /^[0-9]+(\.[0-9]+)+(-rc[0-9]+)?$/ - # Publish DrevOps installer. - drevops-dev-deploy-installer: requires: diff --git a/.drevops/docs/.utils/composer.json b/.drevops/docs/.utils/composer.json index 772bb4f12..eb6b09ab2 100644 --- a/.drevops/docs/.utils/composer.json +++ b/.drevops/docs/.utils/composer.json @@ -1,6 +1,7 @@ { "name": "drevops/docs", "require": { + "php": ">=8.1", "alexskrypnyk/shellvar": "^0.5" }, "authors": [ diff --git a/.drevops/docs/.utils/composer.lock b/.drevops/docs/.utils/composer.lock index 1a4e08b47..211c39abd 100644 --- a/.drevops/docs/.utils/composer.lock +++ b/.drevops/docs/.utils/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "580469662bdd2de74e9899d79bfeea53", + "content-hash": "db125c74d5df86541dcb97dc427eeeb9", "packages": [ { "name": "alexskrypnyk/csvtable", @@ -778,7 +778,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.1" + }, "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/.drevops/docs/.utils/publish.sh b/.drevops/docs/.utils/publish.sh index c16dfd862..544fe8bdb 100755 --- a/.drevops/docs/.utils/publish.sh +++ b/.drevops/docs/.utils/publish.sh @@ -210,6 +210,8 @@ push_to_remote() { # Directory with files to push to remote. local src_dir="${1:-}" + echo "Pushing ${src_dir} to remote." + configure_ssh # Temp directory to use for the local repo. diff --git a/.drevops/installer/src/Command/InstallCommand.php b/.drevops/installer/src/Command/InstallCommand.php index c9b39b91c..8052720a2 100644 --- a/.drevops/installer/src/Command/InstallCommand.php +++ b/.drevops/installer/src/Command/InstallCommand.php @@ -567,6 +567,9 @@ protected function processDrevopsInternal($dir) { static::rmdirRecursive("$dir/.drevops/tests"); static::rmdirRecursive("$dir/scripts/drevops/utils"); @unlink("$dir/.github/FUNDING.yml"); + foreach (glob("$dir/.github/drevops-*.yml") as $file) { + @unlink($file); + } // Remove other unhandled tokenized comments. $this->removeTokenLine('#;<', $dir); diff --git a/.drevops/tests/bats/_helper.bash b/.drevops/tests/bats/_helper.bash index ae00e386d..cae306f18 100644 --- a/.drevops/tests/bats/_helper.bash +++ b/.drevops/tests/bats/_helper.bash @@ -414,6 +414,7 @@ assert_files_present_drevops() { assert_dir_not_exists ".drevops" assert_file_not_exists "LICENSE" assert_file_not_exists ".github/FUNDING.yml" + assert_file_not_exists ".github/drevops-publish-docs.yml" assert_file_not_contains ".circleci/config.yml" "drevops-dev-test" assert_file_not_contains ".circleci/config.yml" "drevops-dev-test-workflow" assert_file_not_contains ".circleci/config.yml" "drevops-dev-test-deployment" diff --git a/.github/workflows/drevops-publish-docs.yml b/.github/workflows/drevops-publish-docs.yml new file mode 100644 index 000000000..bea3694d7 --- /dev/null +++ b/.github/workflows/drevops-publish-docs.yml @@ -0,0 +1,53 @@ +# This action is used for DrevOps maintenance. It will not be used in the scaffolded project. +name: Publish documentation to GitHub Pages for DrevOps + +on: + push: + tags: + - '*' + branches: + - main + - develop + - /^.*docs.*$/ + +jobs: + drevops-publish-docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install Ahoy + run: os=$(uname -s | tr [:upper:] [:lower:]) && architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) && sudo wget -q https://github.com/ahoy-cli/ahoy/releases/latest/download/ahoy-bin-$os-$architecture -O /usr/local/bin/ahoy && sudo chown $USER /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy + + - name: Install Aspell + run: sudo apt-get update -y && sudo apt-get install -y aspell + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + + - name: Build and test docs + run: | + cd .drevops/docs + ahoy build + ahoy lint + ahoy test + + - name: Setup SSH private key + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.DOCS_PUBLISH_SSH_PRIVATE_KEY }} + + - name: Publish docs + run: | + cd .drevops/docs + export DOCS_PUBLISH_REMOTE_URL=git@github.com:drevops/drevops_docs.git + export DOCS_PUBLISH_SRC_TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }} + export DOCS_PUBLISH_SRC_BRANCH=${{ github.ref_type == 'branch' && github.ref_name || '' }} + export DOCS_PUBLISH_CANARY_BRANCH="develop" + export DOCS_PUBLISH_COMMIT_MESSAGE="Automatically pushed from drevops/drevops" + export DOCS_PUBLISH_GIT_EMAIL="deployer@drevops.com" + ./.utils/publish.sh