Switch from CircleCI to GH Actions (#854)

* Switch from CircleCI to GH Actions

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>

* Remove references to CircleCI

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>

* try making a change

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>

* Revert change

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>

* don't need this line

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>

---------

Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
This commit is contained in:
Chris Abraham 2024-05-30 16:26:47 +07:00 committed by GitHub
parent af9a660602
commit 261c517ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 399 additions and 355 deletions

View File

@ -1,184 +0,0 @@
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
defaults: &defaults
docker:
- image: quay.io/pantheon-public/build-tools-ci:6.x
working_directory: ~/example_wordpress_composer
environment:
#=========================================================================
# In addition to the environment variables defined in this file, also
# add the following variables in the Circle CI UI.
#
# See: https://circleci.com/docs/2.0/environment-variables/
#
# TERMINUS_SITE: Name of the Pantheon site to run tests on, e.g. my_site.
# TERMINUS_TOKEN: The Pantheon machine token.
# GITHUB_TOKEN: The GitHub personal access token.
# GIT_EMAIL: The email address to use when making commits.
#
# TEST_SITE_NAME: The name of the test site to provide when installing.
# ADMIN_PASSWORD: The admin password to use when installing.
# ADMIN_EMAIL: The email address to give the admin when installing.
#=========================================================================
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
# The variables below usually do not need to be modified.
#======================================================================================================================================
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
# Once environment variables can be expanded the variables below can be uncommented and the EXPORTs in set-up-globals.sh can be removed
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
#======================================================================================================================================
# See set-up-globals.sh for more environment variables
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
ADMIN_USERNAME: admin
# BUILD_TOOLS_VERSION: 2.0.0-beta6
TERM: dumb
version: 2.1
orbs:
slack: circleci/slack@3.4.2
jobs:
# @todo: common initialization, maybe
build:
<<: *defaults
# override the default image with drupaldocker/php as this job
# doesn't need Pantheon specific items such as Terminus that are
# in the quay.io/pantheon-public/build-tools-ci image
docker:
- image: drupaldocker/php:7.2-cli
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- restore_cache:
keys:
- composer-cache
- run:
name: install dev dependencies
command: composer install --no-ansi --no-interaction --optimize-autoloader --no-progress
- save_cache:
key: composer-cache
paths:
- $HOME/.composer/cache
- persist_to_workspace:
# Must be relative path from working_directory
root: .
# Must be relative path from root
paths:
- vendor
- slack/status:
fail_only: true
code_sniff_unit_test:
<<: *defaults
# override the default image with drupaldocker/php as this job
# doesn't need Pantheon specific items such as Terminus that are
# in the quay.io/pantheon-public/build-tools-ci image
docker:
- image: drupaldocker/php:7.2-cli
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: /tmp
- run:
name: copy vendor/web
command: cp -r /tmp/vendor .
- run:
name: check for WordPress coding standards
command: composer -n code-sniff
- slack/status:
fail_only: true
build_css_js:
<<: *defaults
docker:
- image: cimg/node:14.19
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- run:
name: Check current version of node
command: node -v
- run:
name: compile css/js
command: 'cd $HOME/example_wordpress_composer/web/wp-content/themes/cncf-twenty-two/; npm install; npm run build'
- persist_to_workspace:
root: web/wp-content/themes/cncf-twenty-two
paths:
- build
- slack/status:
fail_only: true
build_and_deploy_cncf:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- composer-cache
- terminus-install
- attach_workspace:
at: /tmp
- run:
name: copy build
command: cp -r /tmp/build $HOME/example_wordpress_composer/web/wp-content/themes/cncf-twenty-two/
- run:
name: dependencies
command: ./.circleci/set-up-globals.sh
- run:
name: build assets
command: composer -n build-assets
- run:
name: deploy to Pantheon
command: ./.circleci/deploy-to-pantheon.sh $TERMINUS_SITE
- slack/status:
success_message: "$COMMIT_AUTHOR's *$CIRCLE_JOB* job has succeeded \n- $COMMIT_HASH: $COMMIT_MESSAGE"
failure_message: "$COMMIT_AUTHOR's *$CIRCLE_JOB* job has failed \n- $COMMIT_HASH: $COMMIT_MESSAGE"
workflows:
build_and_test:
jobs:
- build
- build_css_js
- build_and_deploy_cncf:
requires:
- build_css_js
- code_sniff_unit_test:
requires:
- build

View File

@ -1,52 +0,0 @@
#!/bin/bash
TERMINUS_S=$1
set -ex
TERMINUS_DOES_MULTIDEV_EXIST()
{
# Return 0 (true in shell scripts) if on main since dev always exists
if [[ ${CIRCLE_BRANCH} == "main" ]]
then
return 0;
fi
# Stash list of Pantheon multidev environments
PANTHEON_MULTIDEV_LIST="$(terminus multidev:list -n ${TERMINUS_S} --format=list --field=Name)"
while read -r multiDev; do
if [[ "${multiDev}" == "$1" ]]
then
return 0;
fi
done <<< "$PANTHEON_MULTIDEV_LIST"
return 1;
}
# I don't know if on non-pull requests CIRCLE_PULL_REQUEST is empty or complete
# absent -z will return true in either cases.
if [[ ${CIRCLE_BRANCH} != "main" && -z ${CIRCLE_PULL_REQUEST} ]];
then
echo -e "CircleCI will only deploy to Pantheon if on the main branch or creating a pull requests.\n"
exit 0;
fi
if ! TERMINUS_DOES_MULTIDEV_EXIST ${TERMINUS_ENV}
then
terminus env:wake -n "$TERMINUS_S.dev"
terminus build:env:create -n "$TERMINUS_S.dev" "$TERMINUS_ENV" --clone-content --yes --notify="$NOTIFY"
else
terminus build:env:push -n "$TERMINUS_S.$TERMINUS_ENV" --yes
fi
# Clear cache
terminus env:clear-cache "$TERMINUS_S.$TERMINUS_ENV"
set +ex
echo 'terminus secrets:set'
terminus secrets:set -n "$TERMINUS_S.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
set -ex
# Cleanup old multidevs
terminus build:env:delete:pr -n "$TERMINUS_S" --yes

View File

@ -1,47 +0,0 @@
#!/bin/bash
TERMINUS_S=$1
echo 'export PATH=$PATH:$HOME/bin:$HOME/terminus/bin' >> $BASH_ENV
echo 'export BRANCH=$(echo $CIRCLE_BRANCH | grep -v '"'"'^\(main\|[0-9]\+.x\)$'"'"')' >> $BASH_ENV
echo 'export PR_ENV=${BRANCH:+pr-$BRANCH}' >> $BASH_ENV
echo 'export CIRCLE_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
# If we are on a pull request
if [[ $CIRCLE_BRANCH != "main" && -n ${CIRCLE_PULL_REQUEST+x} ]]
then
# Then use a pr- branch/multidev
PR_NUMBER=${CIRCLE_PULL_REQUEST##*/}
PR_BRANCH="pr-${PR_NUMBER}"
echo "export DEFAULT_ENV=pr-${PR_NUMBER}" >> $BASH_ENV
else
# otherwise make the branch name multidev friendly
if [[ $CIRCLE_BRANCH == "main" ]]
then
echo "export DEFAULT_ENV=dev" >> $BASH_ENV
else
echo 'export DEFAULT_ENV=$(echo ${PR_ENV:-$CIRCLE_ENV} | tr '"'"'[:upper:]'"'"' '"'"'[:lower:]'"'"' | sed '"'"'s/[^0-9a-z-]//g'"'"' | cut -c -11 | sed '"'"'s/-$//'"'"')' >> $BASH_ENV
fi
fi
echo 'export TERMINUS_ENV=${TERMINUS_ENV:-$DEFAULT_ENV}' >> $BASH_ENV
source $BASH_ENV
if [[ (${CIRCLE_BRANCH} != "main" && -z ${CIRCLE_PULL_REQUEST+x}) || (${CIRCLE_BRANCH} == "main" && -n ${CIRCLE_PULL_REQUEST+x}) ]];
then
echo -e "CircleCI will only run tests if on the main branch or creating a pull request.\n"
exit 0;
fi
# Bail if required environment varaibles are missing
if [ -z "$TERMINUS_S" ] || [ -z "$TERMINUS_ENV" ]
then
echo 'No test site specified. Set TERMINUS_SITE and TERMINUS_ENV.'
exit 1
fi
# Exit immediately on errors
set -ex
# Install Percy
npm install -D @percy/script
# Run the tests
npx percy exec -- node ./percy/percy.js https://$TERMINUS_ENV-$TERMINUS_S.pantheonsite.io/

View File

@ -1,68 +0,0 @@
#!/bin/bash
set -ex
#=====================================================================================================================
# Start EXPORTing needed environment variables
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
# Once environment variables can be expanded this section can be removed
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
#=====================================================================================================================
echo 'export PATH=$PATH:$HOME/bin:$HOME/terminus/bin' >> $BASH_ENV
echo 'export BRANCH=$(echo $CIRCLE_BRANCH | grep -v '"'"'^\(main\|[0-9]\+.x\)$'"'"')' >> $BASH_ENV
echo 'export PR_ENV=${BRANCH:+pr-$BRANCH}' >> $BASH_ENV
echo 'export CIRCLE_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
# If we are on a pull request
if [[ $CIRCLE_BRANCH != "main" && -n ${CIRCLE_PULL_REQUEST+x} ]]
then
# Then use a pr- branch/multidev
PR_NUMBER=${CIRCLE_PULL_REQUEST##*/}
PR_BRANCH="pr-${PR_NUMBER}"
echo "export DEFAULT_ENV=pr-${PR_NUMBER}" >> $BASH_ENV
else
# otherwise make the branch name multidev friendly
if [[ $CIRCLE_BRANCH == "main" ]]
then
echo "export DEFAULT_ENV=dev" >> $BASH_ENV
else
echo 'export DEFAULT_ENV=$(echo ${PR_ENV:-$CIRCLE_ENV} | tr '"'"'[:upper:]'"'"' '"'"'[:lower:]'"'"' | sed '"'"'s/[^0-9a-z-]//g'"'"' | cut -c -11 | sed '"'"'s/-$//'"'"')' >> $BASH_ENV
fi
fi
echo 'export TERMINUS_ENV=${TERMINUS_ENV:-$DEFAULT_ENV}' >> $BASH_ENV
# Store github info
echo 'export COMMIT_MESSAGE=$(git log --format="%s" -n 1 $CIRCLE_SHA1)' >> $BASH_ENV
echo 'export COMMIT_AUTHOR=$(git log --format="%an" -n 1 $CIRCLE_SHA1)' >> $BASH_ENV
echo 'export COMMIT_HASH=$(git log --format="%h" -n 1 $CIRCLE_SHA1)' >> $BASH_ENV
source $BASH_ENV
#===========================================
# End EXPORTing needed environment variables
#===========================================
# Add a Git token for Composer
if [ -n "$GITHUB_TOKEN" ] ; then
composer config --global github-oauth.github.com $GITHUB_TOKEN
fi
# Bail on errors
set +ex
# Make sure Terminus is installed
terminus --version
# Authenticate with Terminus
terminus auth:login -n --machine-token="$TERMINUS_TOKEN"
# Disable host checking
touch $HOME/.ssh/config
echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
# Configure Git credentials
git config --global user.email "$GIT_EMAIL"
git config --global user.name "Circle CI"
# Ignore file permissions.
git config --global core.fileMode false

View File

@ -0,0 +1,207 @@
name: Build, test and deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
env:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
NOTIFY: 'scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'
TERM: dumb
GITHUB_TOKEN: ${{ github.token }}
TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }}
TERMINUS_SITE: ${{ secrets.TERMINUS_SITE }}
BASH_ENV: "./bash_env.txt"
GITHUB_REF: ${{ github.ref }}
COMMIT_SHA: ${{ github.sha }}
CI_BUILD_NUMBER: ${{ github.run_number }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
GITHUB_OWNER: ${{ github.repository_owner }}
CI_PROJECT_NAME: ${{ github.repository }}
DEFAULT_BRANCH: "main"
jobs:
configure_env_vars:
container:
image: quay.io/pantheon-public/build-tools-ci:6.x
options: --user root
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache bash_env.txt
uses: actions/cache@v4
env:
cache-name: cache-bash-env
with:
path: bash_env.txt
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_number }}
- name: setup-environment-vars
run: |
if [[ "$GITHUB_REF" =~ ^refs/pull/([0-9]+)/merge$ ]]; then
export PR_NUMBER=${BASH_REMATCH[1]}
export CI_BRANCH=`curl -u "${GITHUB_OWNER}:${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.groot-preview+json" \
"https://api.github.com/repos/${CI_PROJECT_NAME}/pulls/${PR_NUMBER}" | \
python3 -c "import sys, json; print(json.load(sys.stdin)['head']['ref'])"`
export CI_PULL_REQUEST=`curl -u "${GITHUB_OWNER}:${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.groot-preview+json" \
"https://api.github.com/repos/${CI_PROJECT_NAME}/pulls/${PR_NUMBER}" | \
python3 -c "import sys, json; print(json.load(sys.stdin)['html_url'])"`
elif [ "$GITHUB_REF" != "refs/heads/main" ]; then
export PR_NUMBER=`curl -u "${GITHUB_OWNER}:${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.groot-preview+json" \
"https://api.github.com/repos/${CI_PROJECT_NAME}/commits/${COMMIT_SHA}/pulls" | \
python3 -c "import sys, json; print(json.load(sys.stdin)[0]['number'])"`
export CI_BRANCH=`curl -u "${GITHUB_OWNER}:${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.groot-preview+json" \
"https://api.github.com/repos/${CI_PROJECT_NAME}/commits/${COMMIT_SHA}/pulls" | \
python3 -c "import sys, json; print(json.load(sys.stdin)[0]['head']['ref'])"`
export CI_PULL_REQUEST=`curl -u "${GITHUB_OWNER}:${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.groot-preview+json" \
"https://api.github.com/repos/${CI_PROJECT_NAME}/commits/${COMMIT_SHA}/pulls" | \
python3 -c "import sys, json; print(json.load(sys.stdin)[0]['html_url'])"`
else
export CI_BRANCH="main"
fi
export CI_PROJECT_REPONAME="${CI_PROJECT_NAME#*/}"
export CI_PROJECT_USERNAME=$GITHUB_REPOSITORY_OWNER
export GITHUB_WORKFLOW_URL=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
./.github/workflows/set-environment
build_site:
container:
image: quay.io/pantheon-public/build-tools-ci:6.x
options: --user root
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache composer cache
uses: actions/cache@v4
env:
cache-name: cache-composer-cache
with:
path: ~/.composer/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('composer.lock') }}
- name: Cache vendor folder
uses: actions/cache@v4
env:
cache-name: cache-vendor
with:
path: ./vendor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('composer.lock') }}
- name: Cache web folder
uses: actions/cache@v4
env:
cache-name: cache-web
with:
path: ./web
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
- name: setup-environment-vars
run: ./.github/workflows/set-environment
- name: run PHP build step
run: composer -n build-assets
- uses: actions/setup-node@v4
with:
node-version: '14.21.3'
- name: Compile css/js
run: cd ./web/wp-content/themes/cncf-twenty-two/; npm install; npm run build
code_sniff_unit_test:
runs-on: ubuntu-latest
container:
image: quay.io/pantheon-public/build-tools-ci:6.x
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build dev dependencies
run: composer install --no-ansi --no-interaction --optimize-autoloader --no-progress
- name: Check code with WordPress coding standards
run: composer -n code-sniff
deploy_to_pantheon:
container:
image: quay.io/pantheon-public/build-tools-ci:6.x
options: --user root
runs-on: ubuntu-latest
needs: [configure_env_vars, build_site]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache bash_env.txt
uses: actions/cache@v4
env:
cache-name: cache-bash-env
with:
path: bash_env.txt
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_number }}
- name: Cache composer cache
uses: actions/cache@v4
env:
cache-name: cache-composer-cache
with:
path: ~/.composer/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('composer.lock') }}
- name: Cache vendor folder
uses: actions/cache@v4
env:
cache-name: cache-vendor
with:
path: ./vendor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('composer.lock') }}
- name: Cache web folder
uses: actions/cache@v4
env:
cache-name: cache-web
with:
path: ./web
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
- name: setup-environment-vars
run: ./.github/workflows/set-environment
# Rsync the build artifact pieces web directory
- name: sync build artifact
run: rsync -rz ./web ./vendor .
# Deploy to Pantheon
- name: deploy to Pantheon
run: |
echo "$SSH_PRIVATE_KEY" > ../private.key
chmod 600 ../private.key
eval `ssh-agent -s`
ssh-add ../private.key
source $BASH_ENV
./.github/workflows/pantheon-deploy $TERMINUS_SITE

37
.github/workflows/pantheon-deploy vendored Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
TERMINUS_S=$1
set -eo pipefail
#
# This script deploys the build artifact to Pantheon.
# On the master branch the dev environment is used.
# Otherwise a multidev environment is used.
#
# Authenticate with Terminus
terminus -n auth:login --machine-token="$TERMINUS_TOKEN"
# Prepare for Pantheon
composer run prepare-for-pantheon
if [[ $CI_BRANCH != $DEFAULT_BRANCH ]]
then
# Create a new multidev environment (or push to an existing one)
terminus -n build:env:create "$TERMINUS_S.dev" "$TERMINUS_ENV" --yes
else
# Push to the dev environment
terminus -n build:env:push "$TERMINUS_S.dev" --yes
fi
# Run update-db to ensure that the cloned database is updated for the new code.
terminus -n wp $TERMINUS_S.$TERMINUS_ENV -- core update-db
# Clear the site environment's cache
terminus -n env:clear-cache "$TERMINUS_S.$TERMINUS_ENV"
# Ensure secrets are set
terminus -n secrets:set "$TERMINUS_S.$TERMINUS_ENV" token "$GITHUB_TOKEN" --file='github-secrets.json' --clear --skip-if-empty
# Delete old multidev environments associated
# with a PR that has been merged or closed.
terminus -n build:env:delete:pr $TERMINUS_S --yes

154
.github/workflows/set-environment vendored Executable file
View File

@ -0,0 +1,154 @@
#!/bin/bash
set -eo pipefail
#
# Before calling this script, set the following environent variables:
#
# - CI_BRANCH: the branch being tested
# - CI_BUILD_NUMBER: monotonically increasing build counter
# - PR_NUMBER: pull request number (if job is from a pull request)
#
# Optionally:
#
# - CI_PULL_REQUEST: URL to the current pull request; used to set PR_NUMBER
# - DEFAULT_SITE: name of the repository; used to set TERMINUS_SITE
#
# Note that any environment variable given above is not set, then
# it will be assigned its value from the corresponding CircleCI
# environment variable.
#
CI_BRANCH=${CI_BRANCH:-$CIRCLE_BRANCH}
CI_BUILD_NUMBER=${CI_BUILD_NUMBER:-$CIRCLE_BUILD_NUM}
CI_PROJECT_NAME=${CI_PROJECT_NAME:-$CIRCLE_PROJECT_REPONAME}
CI_PULL_REQUEST=${CI_PULL_REQUEST:-$CIRCLE_PULL_REQUEST}
# Circle sets both $CIRCLE_PULL_REQUEST and $CI_PULL_REQUEST.
PR_NUMBER=${PR_NUMBER:-$CI_PULL_REQUEST}
PR_NUMBER=${PR_NUMBER##*/}
# Set up BASH_ENV if it was not set for us.
BASH_ENV=${BASH_ENV:-$HOME/.bashrc}
# Provide a default email address
GIT_EMAIL=${GIT_EMAIL:-ci-bot@pantheon.io}
# We will also set the default site name to be the same as the repository name.
DEFAULT_SITE=${DEFAULT_SITE:-$CI_PROJECT_NAME}
# By default, we will make the main branch master.
DEFAULT_BRANCH=${DEFAULT_BRANCH:-master}
# If we are on the default branch.
if [[ ${CI_BRANCH} == ${DEFAULT_BRANCH} ]] ; then
# Use dev as the environment.
DEFAULT_ENV=${DEFAULT_ENV:-dev}
else
# Otherwise, name the environment after the CI build number.
DEFAULT_ENV=ci-$CI_BUILD_NUMBER
fi
# If there is a PR number provided, though, then we will use it instead.
if [[ -n ${PR_NUMBER} ]] ; then
DEFAULT_ENV="pr-${PR_NUMBER}"
fi
CI_PR_URL=${CI_PR_URL:-$CIRCLE_PULL_REQUEST}
CI_PROJECT_USERNAME=${CI_PROJECT_USERNAME:-$CIRCLE_PROJECT_USERNAME}
CI_PROJECT_REPONAME=${CI_PROJECT_REPONAME:-$CIRCLE_PROJECT_REPONAME}
TERMINUS_SITE=${TERMINUS_SITE:-$DEFAULT_SITE}
TERMINUS_ENV=${TERMINUS_ENV:-$DEFAULT_ENV}
# If any Pantheon environments are locked, users may provide a URL-encoded
# 'username:password' string in an environment variable to include the
# HTTP Basic Authentication.
MULTIDEV_SITE_BASIC_AUTH=${MULTIDEV_SITE_BASIC_AUTH:-$SITE_BASIC_AUTH}
DEV_SITE_BASIC_AUTH=${DEV_SITE_BASIC_AUTH:-$SITE_BASIC_AUTH}
TEST_SITE_BASIC_AUTH=${TEST_SITE_BASIC_AUTH:-$SITE_BASIC_AUTH}
LIVE_SITE_BASIC_AUTH=${LIVE_SITE_BASIC_AUTH:-$SITE_BASIC_AUTH}
# Prepare the Basic Authentication strings, appending the "@" sign if not empty.
MULTIDEV_SITE_BASIC_AUTH=${MULTIDEV_SITE_BASIC_AUTH:+"$MULTIDEV_SITE_BASIC_AUTH@"}
DEV_SITE_BASIC_AUTH=${DEV_SITE_BASIC_AUTH:+"$DEV_SITE_BASIC_AUTH@"}
TEST_SITE_BASIC_AUTH=${TEST_SITE_BASIC_AUTH:+"$TEST_SITE_BASIC_AUTH@"}
LIVE_SITE_BASIC_AUTH=${LIVE_SITE_BASIC_AUTH:+"$LIVE_SITE_BASIC_AUTH@"}
#=====================================================================================================================
# EXPORT needed environment variables
#
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
# Once environment variables can be expanded this section can be removed
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
# Bitbucket has similar issues:
# https://bitbucket.org/site/master/issues/18262/feature-request-pipeline-command-to-modify
#=====================================================================================================================
(
echo 'export PATH=$PATH:$HOME/bin'
echo "export PR_NUMBER=$PR_NUMBER"
echo "export CI_BRANCH=$(echo $CI_BRANCH | grep -v '"'^\(master\|[0-9]\+.x\)$'"')"
echo "export CI_BUILD_NUMBER=$CI_BUILD_NUMBER"
echo "export DEFAULT_SITE='$DEFAULT_SITE'"
echo "export CI_PR_URL='$CI_PR_URL'"
echo "export CI_PROJECT_USERNAME='$CI_PROJECT_USERNAME'"
echo "export CI_PROJECT_REPONAME='$CI_PROJECT_REPONAME'"
echo "export DEFAULT_ENV='$DEFAULT_ENV'"
echo 'export TERMINUS_HIDE_UPDATE_MESSAGE=1'
echo "export TERMINUS_SITE='$TERMINUS_SITE'"
echo "export TERMINUS_ENV='$TERMINUS_ENV'"
echo "export DEFAULT_BRANCH='$DEFAULT_BRANCH'"
echo "export MULTIDEV_SITE_URL='https://${MULTIDEV_SITE_BASIC_AUTH}$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io/'"
echo "export DEV_SITE_URL='https://${DEV_SITE_BASIC_AUTH}dev-$TERMINUS_SITE.pantheonsite.io/'"
echo "export TEST_SITE_URL='https://${TEST_SITE_BASIC_AUTH}test-$TERMINUS_SITE.pantheonsite.io/'"
echo "export LIVE_SITE_URL='https://${LIVE_SITE_BASIC_AUTH}live-$TERMINUS_SITE.pantheonsite.io/'"
echo "export ARTIFACTS_DIR='artifacts'"
echo "export ARTIFACTS_FULL_DIR='/tmp/artifacts'"
echo "export CI_BUILD_URL='${GITHUB_WORKFLOW_URL}'"
echo "export CI_NODE_INDEX=0"
echo "export CI_REPOSITORY_URL='https://github.com/${GITHUB_REPOSITORY}'"
echo "export ARTIFACTS_DIR_URL='${GITHUB_WORKFLOW_URL}/#artifacts'"
) >> $BASH_ENV
# If a Terminus machine token and site name are defined
if [[ -n "$TERMINUS_MACHINE_TOKEN" && -n "$TERMINUS_SITE" ]]
then
# Authenticate with Terminus
terminus -n auth:login --machine-token="$TERMINUS_MACHINE_TOKEN" > /dev/null 2>&1
# Use Terminus to fetch variables
TERMINUS_SITE_UUID=$(terminus site:info $TERMINUS_SITE --field=id)
# And add those variables to $BASH_ENV
(
echo "export TERMINUS_SITE_UUID='$TERMINUS_SITE_UUID'"
) >> $BASH_ENV
fi
source $BASH_ENV
echo 'Contents of BASH_ENV:'
cat $BASH_ENV
echo
# Avoid ssh prompting when connecting to new ssh hosts
mkdir -p $HOME/.ssh && echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
# Configure the GitHub Oauth token if it is available
if [ -n "$GITHUB_TOKEN" ]; then
composer -n config --global github-oauth.github.com $GITHUB_TOKEN
fi
# Set up our default git config settings if git is available.
git config --global user.email "${GIT_EMAIL:-no-reply+ci-$CI_BUILD_NUMBER@getpantheon.com}"
git config --global user.name "CI Bot"
git config --global core.fileMode false
# Re-install the Terminus Build Tools plugin if requested
if [ -n $BUILD_TOOLS_VERSION ] && [ "$BUILD_TOOLS_VERSION" <> 'dev-master' ]; then
echo "Install Terminus Build Tools Plugin version $BUILD_TOOLS_VERSION."
echo "Note that it is NOT RECOMMENDED to define BUILD_TOOLS_VERSION, save in the Terminus Build Tools plugin tests themselves. All other tests should use the version bundled with the container."
rm -rf ${TERMINUS_PLUGINS_DIR:-~/.terminus/plugins}/terminus-build-tools-plugin
composer -n create-project --no-dev -d ${TERMINUS_PLUGINS_DIR:-~/.terminus/plugins} pantheon-systems/terminus-build-tools-plugin:$BUILD_TOOLS_VERSION
fi

1
.gitignore vendored
View File

@ -34,7 +34,6 @@ web/private/*
!web/private/scripts/
web/private/scripts/quicksilver
!web/private/config/
!.circleci
# Add directories containing build assets below.
# Keep all additions above the "cut" line.

View File

@ -1,5 +1,3 @@
[![CircleCI](https://circleci.com/gh/cncf/cncf.io.svg?style=svg)](https://circleci.com/gh/cncf/cncf.io)
# Contributing to CNCF.io
Everyone is welcome to contribute to this project. We've created a document that describes guidelines for [contributing to the CNCF.io git repository](/CONTRIBUTING.md).
@ -125,7 +123,7 @@ To activate Browsersync to watch files, run `lando npm start` in the theme direc
## Code Sniffs
The CircleCI process will sniff the code to make sure it complies with WordPress coding standards. All Linux Foundation code should comply with [these guidelines](https://docs.google.com/document/d/1TYqCwG874i6PdJDf5UX9gnCZaarvf121G1GdNH7Vl5k/edit#heading=h.dz20heii56uf).
The CI process will sniff the code to make sure it complies with WordPress coding standards. All Linux Foundation code should comply with [these guidelines](https://docs.google.com/document/d/1TYqCwG874i6PdJDf5UX9gnCZaarvf121G1GdNH7Vl5k/edit#heading=h.dz20heii56uf).
phpcs and the [WordPress Coding Standards for PHP_CodeSniffer](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) come as part of the repo and are installed in the vendor directory by composer.