temporarily gitignore sage test to create multidev #47
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sage Install Tests | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '/private/scripts/**' | |
jobs: | |
test: | |
name: Sage Install Tests | |
env: | |
TERM: xterm-256color | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
php-version: [8.0, 8.1, 8.2] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install SSH keys | |
uses: webfactory/ssh-agent@v0.5.0 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Get PR number | |
id: pr | |
run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
- name: Generate multidev name | |
id: generate_name | |
run: | | |
os_short="" | |
case "${{ matrix.os }}" in | |
ubuntu-latest) | |
os_short="nix" | |
;; | |
macos-latest) | |
os_short="mac" | |
;; | |
windows-latest) | |
os_short="win" | |
;; | |
esac | |
php_short=$(echo "${{ matrix.php-version }}" | tr -d '.') | |
pr_num=$(echo ${{ steps.pr.outputs.pull_request_number }}) | |
echo "PR number: $pr_num" | |
echo "OS: $os_short" | |
echo "PHP: $php_short" | |
multidev_name="${os_short}-${php_short}-${pr_num}" | |
echo "Generated multidev name: $multidev_name" | |
echo "multidev_name=$multidev_name" >> $GITHUB_ENV | |
- name: Get latest Terminus release | |
run: | | |
latest_version=$(curl --silent "https://api.github.com/repos/pantheon-systems/terminus/releases/latest" | jq -r .tag_name) | |
echo "Latest Terminus version: $latest_version" | |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
echo "☕ Installing Terminus on macOS from Homebrew..." | |
brew install pantheon-systems/external/terminus | |
else | |
echo "💻 Installing Terminus from phar on Linux..." | |
curl -L "https://github.com/pantheon-systems/terminus/releases/download/$latest_version/terminus.phar" -o terminus | |
chmod +x terminus | |
sudo mv terminus /usr/local/bin/ | |
fi | |
# Test that terminus works... | |
terminus --version | |
- name: Validate Pantheon Host Key | |
run: | | |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config | |
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config | |
echo "StrictHostKeyChecking no" >> ~/.ssh/config | |
- name: Log into Terminus and Check for updates | |
run: | | |
terminus auth:login --machine-token=${{ secrets.TERMINUS_TOKEN }} | |
terminus upstream:updates:apply wpcm-sage-install-tests.dev --accept-upstream | |
- name: Clone site and create multidev | |
run: | | |
echo "Cloning site..." | |
terminus local:clone wpcm-sage-install-tests | |
cd ~/pantheon-local-copies/wpcm-sage-install-tests | |
if [[ -n $(git status --porcelain) ]]; then | |
echo "❌ Local clone is dirty. Exiting..." | |
exit 1 | |
fi | |
# If sage-test exists, delete it. | |
if [[ -d "web/app/themes/sage-test" ]]; then | |
echo "Deleting existing sage-test..." | |
rm -rf web/app/themes/sage-test | |
fi | |
# Temporarily gitignore web/apps/themes/sage-test. | |
echo "web/app/themes/sage-test" >> .gitignore | |
terminus multidev:create wpcm-sage-install-tests.dev $multidev_name | |
echo "Checking out multidev..." | |
git fetch --all | |
git checkout $multidev_name | |
# Remove web/app/themes/sage-test from .gitignore. | |
sed -i '' '/web\/app\/themes\/sage-test/d' .gitignore | |
- name: Copy latest repository changes | |
run: | | |
# Sync the files from checked-out repo to pantheon-local-copies, excluding the .git folder | |
rsync -av --exclude='.git/' ${{ github.workspace }}/ ~/pantheon-local-copies/wpcm-sage-install-tests/ | |
# Navigate to Pantheon local copies directory | |
cd ~/pantheon-local-copies/wpcm-sage-install-tests/ | |
git config --global user.email "bot@getpantheon.com" | |
git config --global user.name "Pantheon TestBot" | |
# Add, commit and push | |
git add . | |
git commit -m "Sync latest changes to test environment" | |
git push origin $multidev_name | |
- name: Install Composer Dependencies | |
run: | | |
cd ~/pantheon-local-copies/wpcm-sage-install-tests | |
composer install | |
- name: Run Sage Install Script | |
run: | | |
export SAGENAME=sage-test | |
export SITENAME=wpcm-sage-install-tests | |
export CI=1 | |
export SITEENV=$multidev_name | |
cd ~/pantheon-local-copies/$SITENAME | |
composer install-sage || exit_code=$? | |
if [[ -n "${exit_code}" ]]; then | |
echo "❌ Sage Install Script Failed with exit code ${exit_code}" | |
exit $exit_code | |
else | |
echo "✅ Sage Install Script passed!" | |
exit 0; | |
fi | |
- name: Delete multidev | |
if: always() | |
run: terminus multidev:delete --delete-branch --yes wpcm-sage-install-tests.$multidev_name |