forked from ramiy/astra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge development workflows to the master branch
PR - #2564 PR - #2549
- Loading branch information
1 parent
82deaf4
commit 362b58d
Showing
21 changed files
with
7,593 additions
and
72 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,15 @@ | ||
name: Auto Cancel | ||
|
||
on: [push] | ||
|
||
jobs: | ||
cancel: | ||
name: 'Cancel Previous Runs' | ||
# Skip if push is from PR fork. | ||
if: github.event.pull_request.head.repo.fork == false | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: styfle/[email protected] | ||
with: | ||
workflow_id: simple-size-check.yml | ||
access_token: ${{ github.token }} |
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,68 @@ | ||
name: Build and Deploy | ||
|
||
# Run the deployment only when code is committed to teh branch. | ||
on: | ||
push: | ||
branches: | ||
- development | ||
- next-release | ||
- dev | ||
- release-candidate | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Get npm cache directory | ||
id: npm-cache | ||
run: echo "::set-output name=dir::$(npm config get cache)" | ||
|
||
- name: Configure npm cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.npm-cache.outputs.dir }} | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-npm- | ||
- name: Build | ||
run: npm install && grunt release-no-clean | ||
|
||
- name: Set environment name | ||
run: | | ||
if [ '${{github.ref}}' = 'refs/heads/development' ] | ||
then | ||
echo "ENVIRONMENT=DEVELOPMENT" >> $GITHUB_ENV | ||
fi | ||
if [ '${{github.ref}}' = 'refs/heads/next-release' ] | ||
then | ||
echo "ENVIRONMENT=NEXT_RELEASE" >> $GITHUB_ENV | ||
fi | ||
if [ '${{github.ref}}' = 'refs/heads/release-candidate' ] | ||
then | ||
echo "ENVIRONMENT=RELEASE_CANDIDATE" >> $GITHUB_ENV | ||
fi | ||
if [ '${{github.ref}}' = 'refs/heads/dev' ] | ||
then | ||
echo "ENVIRONMENT=RELEASE_CANDIDATE" >> $GITHUB_ENV | ||
fi | ||
if [ '${{github.ref}}' = 'refs/heads/master' ] | ||
then | ||
echo "ENVIRONMENT=MASTER" >> $GITHUB_ENV | ||
fi | ||
- name: Rsync Deployment | ||
uses: burnett01/[email protected] | ||
with: | ||
switches: -avzr --delete | ||
path: astra/* | ||
remote_path: ${{ secrets[format('SSH_PATH_{0}', env.ENVIRONMENT)] }} | ||
remote_host: ${{ secrets.SSH_HOST }} | ||
remote_user: ${{ secrets.SSH_USERNAME }} | ||
remote_key: ${{ secrets.SSH_KEY }} | ||
|
||
- name: Cleanup | ||
run: rm -rf astra/ |
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,49 @@ | ||
name: Simple Asset Size Reporter | ||
|
||
# Run the deployment only when code is committed to the branch. | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
assetSizeReporter: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Get npm cache directory | ||
id: npm-cache | ||
run: echo "::set-output name=dir::$(npm config get cache)" | ||
|
||
- name: Configure npm cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.npm-cache.outputs.dir }} | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-npm- | ||
- name: npm install, build | ||
run: | | ||
npm install | ||
- name: Start Docker environment | ||
run: npm run env:start | ||
env: | ||
COMPOSE_INTERACTIVE_NO_CLI: true | ||
|
||
- uses: preactjs/compressed-size-action@v2 | ||
with: | ||
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
# Any JS files anywhere within a dist directory: | ||
pattern: "{assets/**/**/*.js,assets/**/**/*.css}" | ||
|
||
# Always ignore SourceMaps and node_modules: | ||
exclude: "{**/*.map,**/node_modules/**}" | ||
build-script: "dynamic-css" | ||
|
||
- name: Stop Docker environment | ||
run: npm run env:stop | ||
if: always() | ||
env: | ||
COMPOSE_INTERACTIVE_]NO_CLI: true |
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 |
---|---|---|
|
@@ -30,3 +30,6 @@ astra | |
# Ignore Composer's directories | ||
vendor/ | ||
cghooks.lock | ||
|
||
# Dynamic CSS file. | ||
assets/dynamic-css.css |
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
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,6 @@ | ||
WORDPRESS_DB_HOST=mysql | ||
WORDPRESS_DB_USER=root | ||
WORDPRESS_DB_PASSWORD=example | ||
WORDPRESS_DB_NAME=wordpress | ||
WORDPRESS_DEBUG=1 | ||
WORDPRESS_CONFIG_EXTRA=define( 'SCRIPT_DEBUG', true ); define( 'FS_METHOD', 'direct' ); |
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,37 @@ | ||
version: '3.1' | ||
|
||
services: | ||
wordpress: | ||
image: wordpress | ||
ports: | ||
- "127.0.0.1:8890:80" | ||
env_file: | ||
- .env.wp | ||
volumes: | ||
- wordpress_data:/var/www/html | ||
- ../../:/var/www/html/wp-content/themes/astra | ||
depends_on: | ||
- mysql | ||
|
||
cli: | ||
image: wordpress:cli | ||
user: xfs | ||
volumes: | ||
- wordpress_data:/var/www/html | ||
- ../../:/var/www/html/wp-content/themes/astra | ||
env_file: | ||
- .env.wp | ||
depends_on: | ||
- mysql | ||
- wordpress | ||
command: tail -f /dev/null | ||
|
||
mysql: | ||
image: mysql:5.7 | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: example | ||
MYSQL_DATABASE: wordpress_test | ||
|
||
volumes: | ||
wordpress_data: |
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,178 @@ | ||
#!/bin/bash | ||
|
||
# Common variables. | ||
DOCKER_COMPOSE_FILE_OPTIONS="-f $(dirname "$0")/docker-compose.yml" | ||
# These are the containers and values for the development site. | ||
CLI='cli' | ||
CONTAINER='wordpress' | ||
DATABASE='mysql' | ||
SITE_TITLE='Astra Dev' | ||
|
||
## | ||
# Ask a Yes/No question, and way for a reply. | ||
# | ||
# This is a general-purpose function to ask Yes/No questions in Bash, either with or without a default | ||
# answer. It keeps repeating the question until it gets a valid answer. | ||
# | ||
# @param {string} prompt The question to ask the user. | ||
# @param {string} [default] Optional. "Y" or "N", for the default option to use if none is entered. | ||
# @param {int} [timeout] Optional. The number of seconds to wait before using the default option. | ||
# | ||
# @returns {bool} true if the user replies Yes, false if the user replies No. | ||
## | ||
ask() { | ||
# Source: https://djm.me/ask | ||
local timeout endtime timediff prompt default reply | ||
|
||
while true; do | ||
|
||
timeout="${3:-}" | ||
|
||
if [ "${2:-}" = "Y" ]; then | ||
prompt="Y/n" | ||
default=Y | ||
elif [ "${2:-}" = "N" ]; then | ||
prompt="y/N" | ||
default=N | ||
else | ||
prompt="y/n" | ||
default= | ||
timeout= | ||
fi | ||
|
||
if [ -z "$timeout" ]; then | ||
# Ask the question (not using "read -p" as it uses stderr not stdout) | ||
echo -en "$1 [$prompt] " | ||
|
||
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else) | ||
read reply </dev/tty | ||
else | ||
endtime=$((`date +%s` + $timeout)); | ||
while [ "$endtime" -ge `date +%s` ]; do | ||
timediff=$(($endtime - `date +%s`)) | ||
|
||
echo -en "\r$1 [$prompt] (Default $default in ${timediff}s) " | ||
read -t 1 reply </dev/tty | ||
|
||
if [ -n "$reply" ]; then | ||
break | ||
fi | ||
done | ||
fi | ||
|
||
# Default? | ||
if [ -z "$reply" ]; then | ||
reply=$default | ||
fi | ||
|
||
# Check if the reply is valid | ||
case "$reply" in | ||
Y*|y*) return 0 ;; | ||
N*|n*) return 1 ;; | ||
esac | ||
|
||
done | ||
} | ||
|
||
## | ||
# Download from a remote source. | ||
# | ||
# Checks for the existence of curl and wget, then downloads the remote file using the first available option. | ||
# | ||
# @param {string} remote The remote file to download. | ||
# @param {string} [local] Optional. The local filename to use. If it isn't passed, STDOUT is used. | ||
# | ||
# @return {bool} Whether the download succeeded or not. | ||
## | ||
download() { | ||
if command_exists "curl"; then | ||
curl -s -o "${2:--}" "$1" | ||
elif command_exists "wget"; then | ||
wget -nv -O "${2:--}" "$1" | ||
fi | ||
} | ||
|
||
## | ||
# Add error message formatting to a string, and echo it. | ||
# | ||
# @param {string} message The string to add formatting to. | ||
## | ||
error_message() { | ||
echo -en "\033[31mERROR\033[0m: $1" | ||
} | ||
|
||
## | ||
# Add warning message formatting to a string, and echo it. | ||
# | ||
# @param {string} message The string to add formatting to. | ||
## | ||
warning_message() { | ||
echo -en "\033[33mWARNING\033[0m: $1" | ||
} | ||
|
||
## | ||
# Add status message formatting to a string, and echo it. | ||
# | ||
# @param {string} message The string to add formatting to. | ||
## | ||
status_message() { | ||
echo -en "\033[32mSTATUS\033[0m: $1" | ||
} | ||
|
||
## | ||
# Add formatting to an action string. | ||
# | ||
# @param {string} message The string to add formatting to. | ||
## | ||
action_format() { | ||
echo -en "\033[32m$1\033[0m" | ||
} | ||
|
||
## | ||
# Check if the command exists as some sort of executable. | ||
# | ||
# The executable form of the command could be an alias, function, builtin, executable file or shell keyword. | ||
# | ||
# @param {string} command The command to check. | ||
# | ||
# @return {bool} Whether the command exists or not. | ||
## | ||
command_exists() { | ||
type -t "$1" >/dev/null 2>&1 | ||
} | ||
|
||
## | ||
# Docker Compose helper | ||
# | ||
# Calls docker-compose with common options. | ||
## | ||
dc() { | ||
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS "$@" | ||
} | ||
|
||
## | ||
# WP CLI | ||
# | ||
# Executes a WP CLI request in the CLI container. | ||
## | ||
wp() { | ||
dc exec -T -u xfs $CLI wp "$@" | ||
} | ||
|
||
## | ||
# MySQL CLI. | ||
# | ||
# Executes the given MySQL client command in the database container. | ||
## | ||
mysql() { | ||
dc exec -T -e MYSQL_PWD=example $DATABASE mysql "$@" | ||
} | ||
|
||
## | ||
# WordPress Container helper. | ||
# | ||
# Executes the given command in the wordpress container. | ||
## | ||
container() { | ||
dc exec -T $CONTAINER "$@" | ||
} |
Oops, something went wrong.