-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CircleCI
committed
Jun 21, 2021
0 parents
commit 11c64aa
Showing
32 changed files
with
2,576 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: humanmade/ci-php:7.3-node | ||
|
||
branches: | ||
only: | ||
# Whitelist branches to build for. | ||
- master | ||
steps: | ||
# Checkout repo & subs: | ||
- checkout | ||
|
||
# Get npm cache: | ||
- restore_cache: | ||
key: npm | ||
|
||
# Build steps: | ||
- run: npm install --production | ||
- run: npm run build | ||
|
||
# Make fast: | ||
- save_cache: | ||
key: npm | ||
paths: | ||
- ~/.npm | ||
|
||
# Run the deploy: | ||
- deploy: | ||
command: .circleci/deploy.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Add files or patterns to exclude from the built branch here. | ||
# Consult the "INCLUDE/EXCLUDE PATTERN RULES" section of the rsync manual for | ||
# supported patterns. | ||
# | ||
# Note: Excluding ".circleci" will cause your branch to fail. Use the | ||
# `branches` option in config.yml instead. | ||
|
||
.git | ||
.gitignore | ||
node_modules | ||
package.json | ||
package-lock.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash -e | ||
# | ||
# Deploy your branch. | ||
# | ||
|
||
DEPLOY_SUFFIX="${DEPLOY_SUFFIX:--built}" | ||
GIT_USER="${DEPLOY_GIT_USER:-CircleCI}" | ||
GIT_EMAIL="${DEPLOY_GIT_EMAIL:-hello@humanmade.com}" | ||
|
||
BRANCH="${CIRCLE_BRANCH}" | ||
SRC_DIR="$PWD" | ||
BUILD_DIR="/tmp/hm-build" | ||
|
||
if [[ -z "$BRANCH" ]]; then | ||
echo "No branch specified!" | ||
exit 1 | ||
fi | ||
|
||
if [[ -d "$BUILD_DIR" ]]; then | ||
echo "WARNING: ${BUILD_DIR} already exists. You may have accidentally cached this" | ||
echo "directory. This will cause issues with deploying." | ||
exit 1 | ||
fi | ||
|
||
COMMIT=$(git rev-parse HEAD) | ||
VERSION=$(grep 'Version: ' plugin.php | grep -oEi '[0-9\.a-z\+-]+$') | ||
|
||
if [[ $VERSION != "null" ]]; then | ||
DEPLOY_BRANCH="${VERSION}--branch" | ||
DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-yes}" | ||
else | ||
DEPLOY_BRANCH="${BRANCH}${DEPLOY_SUFFIX}" | ||
DEPLOY_AS_RELEASE="${DEPLOY_AS_RELEASE:-no}" | ||
fi | ||
|
||
echo "Deploying $BRANCH to $DEPLOY_BRANCH" | ||
|
||
# If the deploy branch doesn't already exist, create it from the empty root. | ||
if ! git rev-parse --verify "remotes/origin/$DEPLOY_BRANCH" >/dev/null 2>&1; then | ||
echo -e "\nCreating $DEPLOY_BRANCH..." | ||
git worktree add --detach "$BUILD_DIR" | ||
cd "$BUILD_DIR" | ||
git checkout --orphan "$DEPLOY_BRANCH" | ||
else | ||
echo "Using existing $DEPLOY_BRANCH" | ||
git worktree add --detach "$BUILD_DIR" "remotes/origin/$DEPLOY_BRANCH" | ||
cd "$BUILD_DIR" | ||
git checkout "$DEPLOY_BRANCH" | ||
fi | ||
|
||
# Ensure we're in the right dir | ||
cd "$BUILD_DIR" | ||
|
||
# Remove existing files | ||
git rm -rfq . | ||
|
||
# Sync built files | ||
echo -e "\nSyncing files..." | ||
if ! command -v 'rsync'; then | ||
sudo apt-get install -q -y rsync | ||
fi | ||
|
||
rsync -av "$SRC_DIR/" "$BUILD_DIR" --exclude-from "$SRC_DIR/.circleci/deploy-exclude.txt" | ||
|
||
# Add changed files | ||
git add . | ||
|
||
if [ -z "$(git status --porcelain)" ]; then | ||
echo "No changes to built files." | ||
exit | ||
fi | ||
|
||
# Print status! | ||
echo -e "\nSynced files. Changed:" | ||
git status -s | ||
|
||
# Double-check our user/email config | ||
if ! git config user.email; then | ||
git config user.name "$GIT_USER" | ||
git config user.email "$GIT_EMAIL" | ||
fi | ||
|
||
# Commit it. | ||
MESSAGE=$( printf 'Build changes from %s\n\n%s' "${COMMIT}" "${CIRCLE_BUILD_URL}" ) | ||
git commit -m "$MESSAGE" | ||
|
||
# Push it (real good). | ||
git push origin "$DEPLOY_BRANCH" | ||
|
||
# Make a release if one doesn't exist. | ||
if [[ $DEPLOY_AS_RELEASE = "yes" && $(git tag -l "$VERSION") != $VERSION ]]; then | ||
git tag "$VERSION" | ||
git push origin "$VERSION" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = tab | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
indent_style = space |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Even though this is a JavaScript file, the config data itself is formatted as JSON to allow for easier comparison, | ||
* as well as copy-and-paste from and to other .eslintrc JSON files. | ||
*/ | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
|
||
module.exports = { | ||
"extends": [ | ||
"plugin:@wordpress/eslint-plugin/recommended", | ||
"plugin:import/errors" | ||
], | ||
"env": { | ||
"browser": true | ||
}, | ||
"plugins": [ | ||
"jsdoc" | ||
], | ||
"rules": { | ||
"@wordpress/dependency-group": "off", | ||
"@wordpress/react-no-unsafe-timeout": "error", | ||
"import/no-unresolved": [ | ||
"error", | ||
{ | ||
"commonjs": true, | ||
"ignore": [ | ||
"^@wordpress\/[^/]+" | ||
] | ||
} | ||
], | ||
"jsdoc/check-param-names": "warn", | ||
"jsdoc/check-tag-names": "warn", | ||
"jsdoc/check-types": [ | ||
"warn", | ||
{ | ||
"noDefaults": true | ||
} | ||
], | ||
"jsdoc/newline-after-description": "warn", | ||
"jsdoc/no-undefined-types": "warn", | ||
"jsdoc/require-description-complete-sentence": "warn", | ||
"jsdoc/require-hyphen-before-param-description": "warn", | ||
"jsdoc/require-param": "warn", | ||
"jsdoc/require-param-description": "warn", | ||
"jsdoc/require-param-name": "warn", | ||
"jsdoc/require-param-type": "warn", | ||
"jsdoc/require-returns-type": "warn", | ||
"jsdoc/valid-types": "warn", | ||
"max-len": [ | ||
"warn", | ||
120 | ||
], | ||
"no-console": isProduction ? "error" : "warn", | ||
"no-debugger": isProduction ? "error" : "warn", | ||
"no-shadow": "off", | ||
"no-unused-vars": [ | ||
"warn", | ||
{ | ||
"vars": "all", | ||
"varsIgnorePattern": "_", | ||
"args": "after-used", | ||
"argsIgnorePattern": "_", | ||
"ignoreRestSiblings": true | ||
} | ||
], | ||
"operator-linebreak": [ | ||
"error", | ||
"before", | ||
{ | ||
"overrides": { | ||
"=": "none" | ||
} | ||
} | ||
], | ||
"react/prop-types": "warn", | ||
"valid-jsdoc": [ | ||
"off", | ||
{} | ||
] | ||
} | ||
}; |
Oops, something went wrong.