Skip to content

updated yml

updated yml #2

Workflow file for this run

name: Continuous Integration and README Update
# Define the events that trigger this workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code from the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Attempt to merge changes from 'main' into the current branch
- name: Merge main into the current branch
run: git merge --no-commit --no-ff origin/main || true
# Step 3: Check for merge conflicts
- name: Check for merge conflicts
run: |
# Check if there are any merge conflicts
if git diff --quiet; then
echo "No merge conflicts found"
else
# Display merge conflicts and fail the workflow
echo "Merge conflicts found. Please resolve conflicts and try again."
git status
exit 1
fi
# Step 4: Install project dependencies
- name: Install dependencies
run: npm install
# Step 5: Run tests
- name: Run tests
run: npm test
# Step 6: Lint code
- name: Lint code
run: |
# Example using ESLint
npm run lint # Make sure your project has ESLint configured and installed as a dependency
# Step 7: Check commit format
- name: Check commit format
run: |
# Add scripts to check commit message format, linting, etc.
# For example, you could use a tool like commitlint
npm run commitlint # Assuming you have a script for commit message linting
# Step 8: Check if the PR can be merged
- name: PR Merge Check
id: merge-check
run: |
# Add checks to determine whether the PR can be merged
# For example, you might want to run additional tests or check approvals
if [additional checks pass]; then
echo "::set-output name=should_merge::true"
else
echo "::set-output name=should_merge::false"
fi
# Step 9: Update README with download and pull request counts
- name: Update README with counts
run: |
DOWNLOAD_COUNT=$(curl -s "https://api.github.com/repos/ksachin7/React-practices/releases" | jq '.[] | .assets | .[] | .download_count' | jq -s add)
PULL_REQUEST_COUNT=$(curl -s "https://api.github.com/repos/ksachin7/React-practices/pulls?state=all" | jq 'length')
sed -i "s/^### Download Count:.*/### Download Count: $DOWNLOAD_COUNT/" README.md
sed -i "s/^### Pull Request Count:.*/### Pull Request Count: $PULL_REQUEST_COUNT/" README.md
git add README.md
git commit -m "Update README with latest download and pull request counts" || echo "No changes to commit"
git push
# Deploy to Vercel if the merge check is successful
deploy_to_vercel:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: |
ui-fundamentals: "https://github.com/ksachin7/React-practices/tree/initial/ui-fundamentals" # Specify the directory where the selected project resides
the-wild-oasis: "https://github.com/ksachin7/React-practices/tree/initial/the-wild-oasis"
# Additional steps specific to your project, such as installing dependencies, running tests, etc.
- name: Deploy ui-fundamentals to Vercel
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.checkout.outputs.path == 'https://github.com/ksachin7/React-practices/tree/initial/ui-fundamentals'
uses: amondnet/vercel-action@v2
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-project-name: ui-fundamentals
- name: Deploy the-wild-oasis to Vercel
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.checkout.outputs.path == 'https://github.com/ksachin7/React-practices/tree/initial/the-wild-oasis'
uses: amondnet/vercel-action@v21
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
# vercel-org-id: your_org_id
vercel-project-name: the-wild-oasis