✅ Update deploy.yml #471
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
# | |
# 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@v4 | |
# 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=bugfix-2.1.x | |
CEXA=config/examples | |
CDEF=config/default | |
BC=Configuration.h | |
AC=Configuration_adv.h | |
shopt -s globstar | |
git config user.email "thinkyhead@users.noreply.github.com" | |
git config user.name "Scott Lahteine" | |
# Copy 'config' to a temporary location | |
TEMP=$( mktemp -d ) ; cp -R config $TEMP | |
# Strip all #error lines | |
IFS=$'\n' | |
for fn in "$TEMP"/config/**/Configuration.h; do sed -e '20,30{/#error/d;}' "$fn" > "$fn~" && mv "$fn~" "$fn" ; done | |
unset IFS | |
# Create 'EXPORT' as a copy of 'init-repo' (README, LICENSE, etc.) | |
echo "- Init $EXPORT branch..." | |
git fetch origin init-repo >/dev/null | |
git checkout origin/init-repo -b $EXPORT >/dev/null || exit | |
# Copy all config files and extras into place | |
echo "- Clone fresh $IMPORT..." | |
cp -R "$TEMP/config" . >/dev/null | |
# Update the %VERSION% in the README.md file | |
echo "- Set VERSION in README.md..." | |
VERS=${EXPORT#release-} | |
sed -E "s/%VERSION%/$VERS/g" README.md > README.md~ && mv README.md~ README.md | |
# Reset configurations to default | |
echo "- Reset configs to default..." | |
IFS=$'\n' | |
for fn in "$CEXA"/**/Configuration*.h ; do cp "$CDEF"/$(basename $fn) "$fn" ; done | |
unset IFS | |
# Commit the 'EXPORT', ready for customizations | |
echo "- Amend root commit with only defaults..." | |
{ git add config/**/Configuration*.h README.md && git commit --amend --no-edit ; } >/dev/null | |
# Get configured Configuration.h & Configuration_adv.h | |
echo "- Apply example config customizations..." | |
find "$TEMP"/config -name 'Configuration*.h' | cpio -pdmv ./config >/dev/null 2>&1 | |
echo "- Apply path labels..." | |
for fn in "$CEXA"/**/Conf*.h; do | |
fldr=$(dirname "$fn") ; fldr=${fldr#*config/} ; fldr=${fldr#examples/} | |
blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") | |
sed -e "${blank_line}i\\ | |
\\ | |
#define CONFIG_EXAMPLES_DIR \"$fldr\"" "$fn" > "$fn~" && mv "$fn~" "$fn" | |
done | |
{ git add config/**/Configuration*.h && git commit -m "Examples Customizations" ; } >/dev/null | |
{ git add . && git commit -m "Examples Extras" ; } >/dev/null | |
echo "- Push to origin/$EXPORT" | |
git push -f origin HEAD:$EXPORT >/dev/null | |
rm -rf $TEMP |