Skip to content

Commit

Permalink
*** TEST Deploy Action TEST ***
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 11, 2022
1 parent d6835b7 commit efe8802
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#
# deploy.yml
#
# Rebuild the bugfix-2.1.x branch whenever 'import-2.1.x' is pushed
#

name: Deploy

on:
push:
branches:
- import-2.1.x

jobs:
deploy:
if: github.repository == 'MarlinFirmware/Configurations'
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

# For each directory containing a changed config file, copy the .h files and build the code:
- name: Deploy bugfix-2.1.x
run: |
IMPORT=import-2.1.x
EXPORT=test-2.1.x
CEXA=config/examples
CDEF=config/default
BC=Configuration.h
AC=Configuration_adv.h
git config user.email "[email protected]"
git config user.name "Scott Lahteine"
echo "- Initializing BASE branch..."
# Copy to a temporary location
TEMP=$( mktemp -d ) ; cp -R config $TEMP
# Strip all #error lines
IFS=$'\n'; set -f
for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do
sed -i~ -e "20,30{/#error/d}" "$fn"
rm "$fn~"
done
unset IFS; set +f
# Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.)
git fetch origin
git checkout origin/init-repo -b BASE || exit
# Copy all config files into place
echo "- Copying configs from fresh $IMPORT..."
cp -R "$TEMP/config" .
echo "- Deleting extras"
# Delete anything that's not a Configuration file
find config -type f \! -name "Configuration*" -exec rm "{}" \;
# Init Cartesian/SCARA/TPARA configurations to default
echo "- Initializing configs to default state..."
find "$CEXA" -name $BC -print0 \
| while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
find "$CEXA" -name $AC -print0 \
| while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
# Update the %VERSION% in the README.md file
VERS=$( echo $EXPORT | sed 's/release-//' )
eval "sed -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
rm -f README.md~
# Commit the 'BASE', ready for customizations
git add . >/dev/null && git commit --amend --no-edit ;#>/dev/null
# Create a new branch from 'BASE' for the final result
echo "- Creating 'built-temp' branch..."
git checkout -b built-temp || exit
# Delete temporary branch
git branch -D BASE 2>/dev/null
echo "- Applying customizations..."
cp -R "$TEMP/config" .
find config -type f \! -name "Configuration*" -exec rm "{}" \;
addpathlabels() {
OIFS="$IFS"
IFS=$'\n'
for fn in $(find config -type f -name "Conf*.h"); do
fldr=$(dirname "$fn")
blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn")
gsed -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"\\ " "$fn"
rm -f "$fn~"
done
IFS="$OIFS"
}
echo "- Applying path labels..."
addpathlabels ;#>/dev/null 2>&1
git add . >/dev/null && git commit -m "Examples Customizations" ;#>/dev/null
echo "- Adding all the extras..."
cp -R "$TEMP/config" .
echo "- Applying path labels..."
addpathlabels ;#>/dev/null 2>&1
git add . >/dev/null && git commit -m "Examples Extras" ;#>/dev/null
echo "- Push the new bugfix-2.1.x branch"
git push -f origin HEAD:$EXPORT
rm -rf $TEMP

0 comments on commit efe8802

Please sign in to comment.