Update from https://github.com/opengisch/teaching-and-talks/commit/fd… #215
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
name: Staging | |
on: | |
push: | |
branches: | |
- staging | |
pull_request: | |
branches: | |
- staging | |
env: | |
BUILD: ./build | |
INDEX: ./build/index.html | |
jobs: | |
update_index_push_to_prod: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Check for './build' and './build/index.html' | |
# Flatten directories | |
# Cleanup | |
# Push to production | |
- name: 🧐 Check for build | |
run: | | |
# ------------ | |
# Ensure files | |
# ------------ | |
declare -a missing | |
if ! [[ -d "$BUILD" ]]; then | |
missing+=("build") | |
fi | |
if ! [[ -f "$INDEX" ]]; then | |
missing+=("build/index.html") | |
fi | |
if ! [[ ${#missing[*]} -eq 0 ]] | |
then | |
echo "::error ::Missing files from 'staging' branch." | |
echo "Missing: ${missing[*]}" | |
exit 1 | |
else | |
exit 0 | |
fi | |
- name: Unpack subfolders to improve page navigation | |
run: mv $BUILD/* . | |
- name: 🧹 Cleanup | |
run: rmdir $BUILD | |
- name: Create .nojekyll file to avoid problems with CSS | |
run: touch .nojekyll | |
- name: 🚠 Push to production | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: Deploying build | |
add: '.' | |
push: origin HEAD:production --force | |