update build with Cloudflare pages deployment #3
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: Build and deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Components and overrides | |
- name: Combine and clean CSS files | |
run: | | |
mkdir -p dist | |
find components overrides -name '*.css' -exec sed -e '/^\/\*/d' -e '/^\*\//d' -e '/^ \* /d' -e '/^\/\//d' {} + >> dist/combined.css | |
- name: Combine and clean JS files | |
run: | | |
find components overrides -name '*.js' -exec sed -e '/^\/\*/d' -e '/^\*\//d' -e '/^ \* /d' -e '/^\/\//d' {} + >> dist/combined.js | |
- name: Add CSS license header and add file | |
run: | | |
cat .github/license-header_css.txt > dist/temp.css | |
cat dist/combined.css >> dist/temp.css | |
mv dist/temp.css dist/combined.css | |
- name: Add JS license header and add file | |
run: | | |
cat .github/license-header_js.txt > dist/temp.js | |
cat dist/combined.js >> dist/temp.js | |
mv dist/temp.js dist/combined.js | |
# Media files | |
- name: Find and add all media | |
run: | | |
mkdir -p dist/media | |
find . -type f \( -name "*.png" -o -name "*.jpg" -o -name "*.webp" \) -exec mv {} dist/media/ \; | |
# README and LICENSE | |
- name: Add repository README and LICENSE | |
run: | | |
mv "$GITHUB_WORKSPACE/README.md" "$GITHUB_WORKSPACE/LICENSE" dist/ | |
# Blog files | |
# (Remove or modify this accordingly) | |
- name: Find and add blog files | |
run: | | |
mkdir -p dist/blog | |
find "$GITHUB_WORKSPACE/blog" -type f -exec mv {} dist/blog/ \; | |
# Build artifact | |
- name: Create build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: combined-files | |
path: dist/ | |
# Deploy build | |
- name: Deploy to Cloudflare Pages | |
uses: cloudflare/pages-action@v1.5.0 | |
with: | |
apiToken: ${{ secrets.CF_PAGES_TOKEN }} | |
accountId: ${{ secrets.CF_PAGES_ACCOUNT_ID }} | |
projectName: ghost-components | |
directory: dist |