From 20f44e749ecf236da0dd1ac2d74b1a218a7c50df Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Mon, 6 May 2024 16:26:59 -0600 Subject: [PATCH] Use `terminus-github-actions` and Sage install script cleanup (#123) * put composer diff into a details block * use terminus-github-actions * skip things for CI-only runs * skip multisite stuff if we're not on multisite * add a workflow:wait to wait for the commit to finish before switching to sftp * bail early if CI rather than continuing if _not_ CI * check if is_multisite is 1 rather than anything, we might get weird output if it's not true * only create the directory if it doesn't exist * wrap statement in quotes * verbose output and ls the contents of /files * log that we're checking for multisite so it looks slightly less weird that we're erroring if it's not * remove ="" * use config is-true rather than config get * genrenate a random theme name * change our grep pattern * use `config is-true` directly * replace spaces with hyphens * remove non alphanumeric characters this will skip weird stuff and make the output more consistent --- .github/workflows/composer-diff.yml | 4 +++- .github/workflows/sage-test.yml | 13 +++++++--- private/scripts/helpers.sh | 37 +++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 14 deletions(-) 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 }} +
diff --git a/.github/workflows/sage-test.yml b/.github/workflows/sage-test.yml index 2ceac2f7..933037b0 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 @@ -157,9 +157,16 @@ jobs: run: | cd ~/pantheon-local-copies/wpcm-sage-install-tests composer update + - name: Generate random theme name + run: | + # Fetch the genre name from the Genrenator API + SAGENAME=$(curl -s https://binaryjazz.us/wp-json/genrenator/v1/genre/) + # 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: - SAGENAME: sage-test + SAGENAME: ${{ env.SAGENAME }} SITENAME: wpcm-sage-install-tests CI: 1 PHPVERSION: ${{ matrix.php-version }} diff --git a/private/scripts/helpers.sh b/private/scripts/helpers.sh index b48d5dc0..14803a35 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 @@ -331,11 +334,15 @@ function add_symlink() { mkdir web/app/uploads/cache fi - # Create a files/cache directory on the host. - sftp -P 2222 "$sftpuser"@"$sftphost" <