Skip to content
4 changes: 4 additions & 0 deletions .github/default-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
labels:
- use-deploys
- initialized

41 changes: 41 additions & 0 deletions .github/workflows/initialize-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ⚙ Initialize PR

on:
pull_request:
branches: [develop, main, shared/*]
types: [opened, reopened]
jobs:
init-pr:
name: Initialized
runs-on: ubuntu-latest
outputs:
drafted: ${{ steps.mark-draft.outputs.drafted || false }}
labeled: ${{ steps.default-label.outputs.labeled || false }}
steps:
- name: Mark as draft
id: mark-draft
shell: bash
continue-on-error: true
run: |
gh pr ready ${{ github.event.pull_request.number }} --undo --repo ${{ github.repository }}
echo "drafted=true" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Default labeling
id: default-label
shell: bash
continue-on-error: true
run: |
if [ -f $GITHUB_WORKSPACE/.github/default-labels.yml ]; then
labels=$(yq e '.labels[]' $GITHUB_WORKSPACE/.github/default-labels.yml)
for label in $labels; do
gh pr edit ${{ github.event.pull_request.number }} --add-label "$label" --repo ${{ github.repository }}
done
echo "labeled=true" >> "$GITHUB_OUTPUT"
else
echo "No default-labels.yml file found"
echo "labeled=false" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/percy-on-demand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Percy On Demand Run

on:
workflow_dispatch:

jobs:
percy-check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2

- name: Install Percy CLI
run: npm install -g @percy/cli

- name: Run Percy check site1
run: |
cd packages/site1
percy snapshot --base-url https://site1-uwh-deploy-test.netlify.app snaplist.yml
env:
PERCY_TOKEN: ${{ secrets["PERCY_TOKEN_site1"] }}
- name: Run Percy check site2
run: |
cd packages/site2
percy snapshot --base-url https://site2-uwh-deploy-test.netlify.app snaplist.yml
env:
PERCY_TOKEN: ${{ secrets["PERCY_TOKEN_site2"] }}
48 changes: 48 additions & 0 deletions netlify-ignore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /bin/bash

# netlify-ignore.sh
# logic based shell script for the Netlify based on enivonment variables
# exiting script with code 1 means build, code 0 means no changes so cancel

# Optional Environmental Inputs:
# ALWAYS_BUILD: true,yes,on,1
# forces an always build
# WATCHED_BUILD_PATHS: example ( "../../common" )
# space separated paths to append to the default git diff statement

# Required Inputs Supplied from Netlify build environment variables
# CACHED_COMMIT_REF
# COMMIT_REF
# SITE_NAME

# Function to display usage
usage() {
echo -e "\033[1;33mUsage: $0 [--no-default-path]\033[0m"
echo -e "\033[1;33mDefault watch build path is set to '.' before other paths are included.\033[0m"
exit 0 # Exit script after printing usage and do not trigger a build
}

# Parse optional flag
DEFAULT_WATCH_BUILD_PATH="."
while [[ "$1" != "" ]]; do
case $1 in
--no-default-path ) DEFAULT_WATCH_BUILD_PATH="" # remove default path
;;
-h | --help ) usage
;;
* ) usage
;;
esac
shift
done

set -x
shopt -s nocasematch
regex="^(build|deploy|build $SITE_NAME|deploy $SITE_NAME)$"

if [[ ! "$WATCHED_BUILD_PATHS" =~ (false|no|off|0) ]]; then BUILD_PATHS="$WATCHED_BUILD_PATHS"; fi;
# shellcheck disable=SC2046
if [[ "$ALWAYS_BUILD" =~ (true|yes|on|1) ]]; then (exit 1);
elif [ "$CACHED_COMMIT_REF" == "$COMMIT_REF" ]; then (exit 1);
elif [[ $(git rev-parse "$COMMIT_REF^{tree}") == $(git rev-parse "$COMMIT_REF^1^{tree}") && $(git -P show -s "$COMMIT_REF" --format=%s ) =~ $regex ]]; then (exit 1);
else git diff --quiet "$CACHED_COMMIT_REF" "$COMMIT_REF" $([[ -n "$DEFAULT_WATCH_BUILD_PATH" ]] && echo "$DEFAULT_WATCH_BUILD_PATH ")$([[ -n "$BUILD_PATHS" ]] && echo " $BUILD_PATHS"); fi;
2 changes: 1 addition & 1 deletion packages/site1/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build]
ignore = "echo $CACHED_COMMIT_REF && echo $COMMIT_REF && git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../common.md"
ignore = "bash ../../netlify-ignore.sh"
#ignore = "exit 1"
command = "sleep 3s && echo 'Site 1 finishes last by 3 seconds' && exit $BUILD_EXIT_CODE"
#command = "echo $CACHED_COMMIT_REF && echo $COMMIT_REF"
Expand Down
2 changes: 1 addition & 1 deletion packages/site2/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build]
ignore = "echo $CACHED_COMMIT_REF && echo $COMMIT_REF && git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../common.md"
ignore = "bash ../../netlify-ignore.sh"
#ignore = "exit 0"
command = "echo $CACHED_COMMIT_REF && echo $COMMIT_REF && exit $BUILD_EXIT_CODE"
base = "packages/site2"
Expand Down
Loading