Skip to content

fix: updated configs & fixed some issues #51

fix: updated configs & fixed some issues

fix: updated configs & fixed some issues #51

Workflow file for this run

on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint_and_test_ui_fundamentals:
name: "Lint and Test UI Fundamentals"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# - name: Change directory to ui-fundamentals
# run: cd ui-fundamentals && ls -a
- name: Install dependencies
working-directory: ui-fundamentals
run: npm install
- name: Lint code
working-directory: ui-fundamentals
run: npm run lint
- name: Test code
working-directory: ui-fundamentals
run: npm test
# for future updates
# lint_and_test_the_wild_oasis:
# name: "Lint and Test The Wild Oasis"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Change directory to the-wild-oasis
# run: cd react-practices/the-wild-oasis
# - name: Install dependencies
# run: npm install
# - name: Lint code
# run: npm run lint
# - name: Test code
# run: npm test
# lint_and_test_movies:
# name: "Lint and Test Movies"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Change directory to movies
# run: cd react-practices/movies
# - name: Install dependencies
# run: npm install
# - name: Lint code
# run: npm run lint
# - name: Test code
# run: npm test
build_and_deploy:
name: "Build and Deploy to Netlify"
runs-on: ubuntu-latest
needs: [
lint_and_test_ui_fundamentals,
# lint_and_test_the_wild_oasis,
# lint_and_test_movies,
]
steps:
- name: Checkout code
uses: actions/checkout@v3
# - name: Change directory to react-practices
# run: cd react-practices
- name: Check for merge conflicts in all projects
run: |
for dir in ui-fundamentals the-wild-oasis movies; do
cd $dir
if git diff --quiet; then
echo "No merge conflicts found in $dir"
else
echo "Merge conflicts found in $dir. Please resolve conflicts and try again."
git status
exit 1
fi
cd ..
done
- name: Deploy if conditions met
run: |
for dir in ui-fundamentals the-wild-oasis movies; do
cd $dir
# Check if there are commits in the branch
# if git diff --name-only HEAD^ HEAD -- $dir; then
# echo "New files added/updated in $dir. Proceeding with deployment."
# Print all the files changed between the parent commit and the current commit
# echo "Files changed:"
# git diff --name-only HEAD^ HEAD -- $dir
npm install
npm run build
# Adjust the NETLIFY_SITE_ID according to the directory/project
case $dir in
"ui-fundamentals")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_UI_FUNDAMENTALS }}"
;;
"the-wild-oasis")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_THE_WILD_OASIS }}"
;;
"movies")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_MOVIES }}"
;;
*)
echo "Unknown project directory: $dir"
exit 1
;;
esac
netlify deploy --prod --message "Deploy from GitHub Actions" --dir=dist --site=$NETLIFY_SITE_ID
# else
# echo "No new files added/updated in $dir. Skipping deployment."
# fi
cd ..
done
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# deploy:
# name: "Deploy to Netlify"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# submodules: recursive
# - name: Install dependencies and build project
# run: |
# cd ui-fundamentals
# npm install
# npm run build
# - name: Netlify Deploy
# uses: jsmrcaga/action-netlify-deploy@v2.1.0
# with:
# # build_directory: ./ui-fundamentals/dist
# NETLIFY_DEPLOY_TO_PROD: true
# deploy-message: "Deploy from GitHub Actions"
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_DEPLOY_TO_PROD: true
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# deploy_to_vercel:
# runs-on: ubuntu-latest
# needs: build
# env:
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# steps:
# # Checkout code including submodules
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# submodules: recursive
# # Change directory to ui-fundamentals
# - name: Change directory to ui-fundamentals
# run: cd ui-fundamentals
# # Install Vercel CLI
# - name: Install Vercel CLI
# run: npm install --global vercel@latest
# # Pull Vercel Environment Information
# - name: Pull Vercel Environment Information
# run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
# # Build Project Artifacts
# - name: Build Project Artifacts
# run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
# # Deploy Project Artifacts to Vercel
# - name: Deploy Project Artifacts to Vercel
# run: |
# vercel deploy --prod --scope=./ui-fundamentals --token=${{ secrets.VERCEL_TOKEN }}