Skip to content

feat: fixed nodejs warnings & added some condition for deployment #56

feat: fixed nodejs warnings & added some condition for deployment

feat: fixed nodejs warnings & added some condition for deployment #56

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@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 16.13.x
# cache: npm
# - 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
- name: Link check (warnings, changed files)
working-directory: ui-fundamentals
run: |
./script/rendered-content-link-checker.mjs \
--language en \
--max 100 \
--check-anchors \
--check-images \
--verbose \
--list $HOME/files.json
# 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@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 16.13.x
# cache: npm
# - 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: Gather files changed
id: gather_files_changed
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
with:
fileOutput: "json"
- name: Deploy if conditions met
run: |
for dir in ui-fundamentals the-wild-oasis movies; do
cd $dir
# Check if there are changed files
if [ -s $HOME/files.json ]; then
echo "Files changed in $dir. Proceeding with deployment..."
# Print all the files changed
echo "Files changed:"
cat $HOME/files.json
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 files changed in $dir. Skipping deployment."
fi
cd ..
done
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
HOME: ${{ github.workspace }}
# 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 }}