Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use terminus-github-actions and Sage install script cleanup #123

Merged
merged 18 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/composer-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
with:
header: composer-diff
message: |
<strong>Composer Changes</strong>
<details>
<summary><strong>Composer Changes</strong></summary>

${{ steps.composer_diff.outputs.composer_diff }}
</details>
13 changes: 10 additions & 3 deletions .github/workflows/sage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
37 changes: 27 additions & 10 deletions private/scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" <<EOF
cd /files
mkdir cache
# Create a files/cache directory on the host if one does not already exist.
echo "Checking if /files/cache exists..."
if [ "$(sftp -P 2222 "$sftpuser"@"$sftphost" <<< "ls /files" | grep -c "/cache[[:space:]]*$")" -eq 0 ]; then
echo "Creating /files/cache directory..."
sftp -P 2222 "$sftpuser"@"$sftphost" <<EOF
cd /files
mkdir cache
EOF
fi

# Switch back to Git mode.
terminus connection:set "$sitename"."$siteenv" git
Expand Down Expand Up @@ -460,8 +467,14 @@ function clean_up() {
exit 1;
fi


# If the site is multisite, we'll need to enable the theme so we can activate it.
terminus wp -- "$sitename"."$siteenv" theme enable "$sagename"
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

# List the themes.
terminus wp -- "$sitename"."$siteenv" theme list

Expand All @@ -475,14 +488,18 @@ function clean_up() {
exit 1;
fi

# If this is a CI environment, stop here.
if [ "$is_ci" == 1 ]; then
echo "${yellow}CI detected. All done here.${normal} 🍵"
exit 0;
fi

# Switch back to SFTP so files can be written.
terminus connection:set "$sitename"."$siteenv" sftp

if [ "$is_ci" -ne 1 ]; then
# 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
# 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

# Commit any additions found in SFTP mode.
echo "${yellow}Committing any files found in SFTP mode that were created by Sage.${normal}"
Expand Down
Loading