From ce2d2a4d10a39cf241c0cd5f2c619933489fc2d0 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 13:44:04 -0600 Subject: [PATCH 01/18] put composer diff into a details block --- .github/workflows/composer-diff.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composer-diff.yml b/.github/workflows/composer-diff.yml index 00e97e01..d484a149 100644 --- a/.github/workflows/composer-diff.yml +++ b/.github/workflows/composer-diff.yml @@ -22,6 +22,8 @@ jobs: with: header: composer-diff message: | - Composer Changes +
+ Composer Changes ${{ steps.composer_diff.outputs.composer_diff }} +
From 8731ee5f14e24c9d068c3ab822dbbb5da9bb99d2 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 13:44:14 -0600 Subject: [PATCH 02/18] use terminus-github-actions --- .github/workflows/sage-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index 2ceac2f7..fdad2828 100644 --- a/.github/workflows/sage-test.yml +++ b/.github/workflows/sage-test.yml @@ -25,9 +25,9 @@ jobs: with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Get latest Terminus release - uses: pantheon-systems/action-terminus-install@v1 + uses: pantheon-systems/terminus-github-actions@v1 with: - os: ${{ matrix.os }} + pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} - name: Validate Pantheon Host Key run: | echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config From 82fe8440cb5c8ce74f9775ce4636254a2dc2ca30 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:17:08 -0600 Subject: [PATCH 03/18] skip things for CI-only runs --- private/scripts/helpers.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index b48d5dc0..ed26fd01 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -475,22 +475,23 @@ function clean_up() { exit 1; fi - # Switch back to SFTP so files can be written. - terminus connection:set "$sitename"."$siteenv" sftp - + # If this is a CI environment, we can skip these steps. if [ "$is_ci" -ne 1 ]; then + # Switch back to SFTP so files can be written. + terminus connection:set "$sitename"."$siteenv" sftp + # Open the site. This should generate requisite files on page load. echo "${yellow}Opening the ${siteenv}-${sitename}.pantheonsite.io to generate requisite files.${normal}" open https://"$siteenv"-"$sitename".pantheonsite.io - fi - # Commit any additions found in SFTP mode. - echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}" - terminus env:commit "$sitename"."$siteenv" --message="[Sage Install] Add any leftover files found in SFTP mode." + # Commit any additions found in SFTP mode. + echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}" + terminus env:commit "$sitename"."$siteenv" --message="[Sage Install] Add any leftover files found in SFTP mode." - # Switch back to Git. - terminus connection:set "$sitename"."$siteenv" git - git pull --ff --commit + # Switch back to Git. + terminus connection:set "$sitename"."$siteenv" git + git pull --ff --commit + fi } # Install Sage theme. From 98b8738b55fe9237e0d82611ee45c6e0835b4f3c Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:17:20 -0600 Subject: [PATCH 04/18] skip multisite stuff if we're not on multisite --- private/scripts/helpers.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index ed26fd01..2e693a29 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -452,6 +452,8 @@ function update_composer() { # Finish up the Sage install process. function clean_up() { + local is_multisite="" + # List the app/themes directory. echo "${yellow}Checking the themes directory for ${sagename}.${normal}" # If the previous output did not include $sagename, bail. @@ -460,8 +462,14 @@ function clean_up() { exit 1; fi + is_multisite=$(terminus wp -- "$sitename"."$siteenv" config get MULTISITE) + # If the site is multisite, we'll need to enable the theme so we can activate it. - terminus wp -- "$sitename"."$siteenv" theme enable "$sagename" + if [ -n "$is_multisite" ]; then + echo "${yellow}Site is multisite.${normal}" + terminus wp -- "$sitename"."$siteenv" theme enable "$sagename" + fi + # List the themes. terminus wp -- "$sitename"."$siteenv" theme list From 5df6f98e47fe7ffaf748fc949a1e0df7b3a9083f Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:26:34 -0600 Subject: [PATCH 05/18] add a workflow:wait to wait for the commit to finish before switching to sftp --- private/scripts/helpers.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 2e693a29..929621e2 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -318,6 +318,9 @@ function install_sage_theme() { # Create the symlink to the cache directory. function add_symlink() { + echo "Waiting for the last step to finish before switching to SFTP mode." + terminus workflow:wait "$sitename"."$siteenv" + # Switch to SFTP mode terminus connection:set "$sitename"."$siteenv" sftp From 8cf11915ec2058003669e214a6e37c32000cc778 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:33:29 -0600 Subject: [PATCH 06/18] bail early if CI rather than continuing if _not_ CI --- private/scripts/helpers.sh | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 929621e2..1a578aa4 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -486,23 +486,26 @@ function clean_up() { exit 1; fi - # If this is a CI environment, we can skip these steps. - if [ "$is_ci" -ne 1 ]; then - # Switch back to SFTP so files can be written. - terminus connection:set "$sitename"."$siteenv" sftp + # If this is a CI environment, stop here. + if [ "$is_ci" == 1 ]; then + echo "${yellow}CI detected. All done here.${normal} 🍵" + exit 0; + fi - # Open the site. This should generate requisite files on page load. - echo "${yellow}Opening the ${siteenv}-${sitename}.pantheonsite.io to generate requisite files.${normal}" - open https://"$siteenv"-"$sitename".pantheonsite.io + # Switch back to SFTP so files can be written. + terminus connection:set "$sitename"."$siteenv" sftp - # Commit any additions found in SFTP mode. - echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}" - terminus env:commit "$sitename"."$siteenv" --message="[Sage Install] Add any leftover files found in SFTP mode." + # Open the site. This should generate requisite files on page load. + echo "${yellow}Opening the ${siteenv}-${sitename}.pantheonsite.io to generate requisite files.${normal}" + open https://"$siteenv"-"$sitename".pantheonsite.io - # Switch back to Git. - terminus connection:set "$sitename"."$siteenv" git - git pull --ff --commit - fi + # Commit any additions found in SFTP mode. + echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}" + terminus env:commit "$sitename"."$siteenv" --message="[Sage Install] Add any leftover files found in SFTP mode." + + # Switch back to Git. + terminus connection:set "$sitename"."$siteenv" git + git pull --ff --commit } # Install Sage theme. From 415b3ada64dbd166af00b9f457413d559776c080 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:50:51 -0600 Subject: [PATCH 07/18] check if is_multisite is 1 rather than anything, we might get weird output if it's not true --- private/scripts/helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 1a578aa4..f6d6b863 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -468,7 +468,7 @@ function clean_up() { is_multisite=$(terminus wp -- "$sitename"."$siteenv" config get MULTISITE) # If the site is multisite, we'll need to enable the theme so we can activate it. - if [ -n "$is_multisite" ]; then + if [ "$is_multisite" == 1 ]; then echo "${yellow}Site is multisite.${normal}" terminus wp -- "$sitename"."$siteenv" theme enable "$sagename" fi From 64e47f449e1e4ec6c57ceae72b451bc1111f61f4 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 14:51:10 -0600 Subject: [PATCH 08/18] only create the directory if it doesn't exist --- private/scripts/helpers.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index f6d6b863..b872af5e 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -334,11 +334,13 @@ function add_symlink() { mkdir web/app/uploads/cache fi - # Create a files/cache directory on the host. - sftp -P 2222 "$sftpuser"@"$sftphost" < Date: Mon, 6 May 2024 14:56:13 -0600 Subject: [PATCH 09/18] wrap statement in quotes --- private/scripts/helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index b872af5e..ef60ee83 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -335,7 +335,7 @@ function add_symlink() { fi # Create a files/cache directory on the host if one does not already exist. - if [ $(sftp -P 2222 "$sftpuser"@"$sftphost" <<< "ls /files" | grep -c "^cache$") -eq 0 ]; then + if [ "$(sftp -P 2222 "$sftpuser"@"$sftphost" <<< "ls /files" | grep -c "^cache$")" -eq 0 ]; then sftp -P 2222 "$sftpuser"@"$sftphost" < Date: Mon, 6 May 2024 15:09:47 -0600 Subject: [PATCH 10/18] verbose output and ls the contents of /files --- private/scripts/helpers.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index ef60ee83..2a751af1 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -336,7 +336,8 @@ function add_symlink() { # Create a files/cache directory on the host if one does not already exist. if [ "$(sftp -P 2222 "$sftpuser"@"$sftphost" <<< "ls /files" | grep -c "^cache$")" -eq 0 ]; then - sftp -P 2222 "$sftpuser"@"$sftphost" < Date: Mon, 6 May 2024 15:12:33 -0600 Subject: [PATCH 11/18] log that we're checking for multisite so it looks slightly less weird that we're erroring if it's not --- private/scripts/helpers.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 2a751af1..c9214178 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -468,6 +468,7 @@ function clean_up() { exit 1; fi + echo "${yellow}Checking if this site is a multisite.${normal}" is_multisite=$(terminus wp -- "$sitename"."$siteenv" config get MULTISITE) # If the site is multisite, we'll need to enable the theme so we can activate it. From 3a75dca9f3b7cad91e1f3b5ee9d1a1a7fe18b0b0 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:12:42 -0600 Subject: [PATCH 12/18] remove ="" --- private/scripts/helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index c9214178..febba11f 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -458,7 +458,7 @@ function update_composer() { # Finish up the Sage install process. function clean_up() { - local is_multisite="" + local is_multisite # List the app/themes directory. echo "${yellow}Checking the themes directory for ${sagename}.${normal}" From 3cc14bd837b6e96b53c763f349234293607f44ae Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:13:24 -0600 Subject: [PATCH 13/18] use config is-true rather than config get --- private/scripts/helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index febba11f..9257f7ac 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -469,7 +469,7 @@ function clean_up() { fi echo "${yellow}Checking if this site is a multisite.${normal}" - is_multisite=$(terminus wp -- "$sitename"."$siteenv" config get MULTISITE) + is_multisite=$(terminus wp -- "$sitename"."$siteenv" config is-true MULTISITE) # If the site is multisite, we'll need to enable the theme so we can activate it. if [ "$is_multisite" == 1 ]; then From 4376d725e5078b6a1949c77ada2667fedd98e1ee Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:26:26 -0600 Subject: [PATCH 14/18] genrenate a random theme name --- .github/workflows/sage-test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index fdad2828..0582beb5 100644 --- a/.github/workflows/sage-test.yml +++ b/.github/workflows/sage-test.yml @@ -157,9 +157,14 @@ jobs: run: | cd ~/pantheon-local-copies/wpcm-sage-install-tests composer update + - name: Generate random theme name + run: | + # Hit https://binaryjazz.us/wp-json/genrenator/v1/genre/ to get a random string we can use as a name. + SAGENAME=$(curl -s https://binaryjazz.us/wp-json/genrenator/v1/genre/) + echo "SAGENAME=$SAGENAME" >> $GITHUB_ENV - name: Run Sage Install Script env: - SAGENAME: sage-test + SAGENAME: ${{ env.SAGENAME }} SITENAME: wpcm-sage-install-tests CI: 1 PHPVERSION: ${{ matrix.php-version }} From f806d09e686242142badec3d3bb84d81c0d025da Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:30:12 -0600 Subject: [PATCH 15/18] change our grep pattern --- private/scripts/helpers.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index 9257f7ac..e7777c99 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -335,9 +335,10 @@ function add_symlink() { fi # Create a files/cache directory on the host if one does not already exist. - if [ "$(sftp -P 2222 "$sftpuser"@"$sftphost" <<< "ls /files" | grep -c "^cache$")" -eq 0 ]; then - sftp -v -P 2222 "$sftpuser"@"$sftphost" < Date: Mon, 6 May 2024 15:36:18 -0600 Subject: [PATCH 16/18] use `config is-true` directly --- private/scripts/helpers.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index e7777c99..14803a35 100755 --- a/private/scripts/helpers.sh +++ b/private/scripts/helpers.sh @@ -459,8 +459,6 @@ function update_composer() { # Finish up the Sage install process. function clean_up() { - local is_multisite - # List the app/themes directory. echo "${yellow}Checking the themes directory for ${sagename}.${normal}" # If the previous output did not include $sagename, bail. @@ -469,11 +467,10 @@ function clean_up() { exit 1; fi - echo "${yellow}Checking if this is a multisite.${normal}" - is_multisite=$(terminus wp -- "$sitename"."$siteenv" config is-true MULTISITE) # If the site is multisite, we'll need to enable the theme so we can activate it. - if [ "$is_multisite" == 1 ]; then + echo "${yellow}Checking if this is a multisite.${normal}" + if terminus wp -- "$sitename"."$siteenv" config is-true MULTISITE; then echo "${yellow}Site is multisite.${normal}" terminus wp -- "$sitename"."$siteenv" theme enable "$sagename" fi From cf187f10b9f87c7a2fbe4fa2f3751eefd5ef7bda Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:38:48 -0600 Subject: [PATCH 17/18] replace spaces with hyphens --- .github/workflows/sage-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index 0582beb5..b48dad1a 100644 --- a/.github/workflows/sage-test.yml +++ b/.github/workflows/sage-test.yml @@ -161,6 +161,8 @@ jobs: run: | # Hit https://binaryjazz.us/wp-json/genrenator/v1/genre/ to get a random string we can use as a name. SAGENAME=$(curl -s https://binaryjazz.us/wp-json/genrenator/v1/genre/) + # Replace spaces with hyphens. + SAGENAME=$(echo $SAGENAME | tr ' ' '-') echo "SAGENAME=$SAGENAME" >> $GITHUB_ENV - name: Run Sage Install Script env: From a53e0e89b7d01cf2b9e994560f604bbafeebd405 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 15:49:59 -0600 Subject: [PATCH 18/18] remove non alphanumeric characters this will skip weird stuff and make the output more consistent --- .github/workflows/sage-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index b48dad1a..933037b0 100644 --- a/.github/workflows/sage-test.yml +++ b/.github/workflows/sage-test.yml @@ -159,10 +159,10 @@ jobs: composer update - name: Generate random theme name run: | - # Hit https://binaryjazz.us/wp-json/genrenator/v1/genre/ to get a random string we can use as a name. + # Fetch the genre name from the Genrenator API SAGENAME=$(curl -s https://binaryjazz.us/wp-json/genrenator/v1/genre/) - # Replace spaces with hyphens. - SAGENAME=$(echo $SAGENAME | tr ' ' '-') + # Replace spaces with hyphens and remove all non-alphanumeric characters except hyphens + SAGENAME=$(echo "$SAGENAME" | tr ' ' '-' | sed 's/[^a-zA-Z0-9\-]//g') echo "SAGENAME=$SAGENAME" >> $GITHUB_ENV - name: Run Sage Install Script env: