add new workflow #77
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 Frontend Challenges | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install platform-specific packages | |
run: | | |
npm install @rollup/rollup-linux-x64-gnu | |
npm i --save-dev @types/node | |
- name: Build and Report | |
id: build-challenges | |
run: | | |
success_problems=() | |
failed_problems=() | |
for problem in problems/*; do | |
if [ -d "$problem" ]; then | |
problem_name=$(basename "$problem") | |
echo "Building $problem_name" | |
cd "$problem/solutions/react-ts" | |
if npm ci && npm run build; then | |
echo "$problem_name build succeeded" | |
success_problems+=("$problem_name") | |
else | |
echo "$problem_name build failed" | |
failed_problems+=("$problem_name") | |
fi | |
cd ../../../../ | |
fi | |
done | |
# Write summary to GITHUB_STEP_SUMMARY with links | |
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "| Challenge Name | Demo | Status |" >> $GITHUB_STEP_SUMMARY | |
echo "|----------------|------|--------|" >> $GITHUB_STEP_SUMMARY | |
for problem in "${success_problems[@]}"; do | |
echo "| $problem | ✅ |" >> $GITHUB_STEP_SUMMARY | |
done | |
for problem in "${failed_problems[@]}"; do | |
echo "| $problem | - | ❌ |" >> $GITHUB_STEP_SUMMARY | |
done |