# GitHub Actions Setup

This repository uses GitHub Actions to automatically update fullPage.js and release new versions. The system monitors both the [fullPage.js repository](https://github.com/alvarotrigo/fullPage.js) and npm registry for updates.

## Repository Structure

- **fullPage.js**: Main library at `alvarotrigo/fullPage.js`
- **react-fullpage**: React wrapper (this repository) at `alvarotrigo/react-fullpage`

## Workflows

### 1. Check Latest fullPage.js (`check-latest-fullpage.yml`)

**Triggers:**
- Daily at 2 AM UTC (scheduled)
- Manual trigger from GitHub Actions tab

**What it does:**
1. Checks the current fullPage.js version in `package.json`
2. Fetches the latest version from **both** npm registry and GitHub releases
3. Compares versions and uses the newest one
4. If there's a newer version, creates a Pull Request to update it
5. The PR includes proper labels and description

### 2. Watch fullPage.js Releases (`watch-fullpage-releases.yml`)

**Triggers:**
- Repository dispatch from fullPage.js repository (when new release is published)
- Manual trigger with version input

**What it does:**
1. Receives notification when fullPage.js has a new release
2. Creates a PR to update to the new version immediately
3. Provides real-time updates when fullPage.js releases are published

### 3. Auto Update fullPage.js (`auto-update-fullpage.yml`)

**Triggers:**
- When a PR that modifies `package.json` is merged to `main`

**What it does:**
1. Detects if fullPage.js version was updated in the merged PR
2. If yes, builds the project and runs tests
3. Bumps the patch version of react-fullpage
4. Creates a GitHub release
5. Publishes to npm

### 4. Manual Update (`manual-update.yml`)

**Triggers:**
- Manual workflow dispatch from GitHub Actions tab

**What it does:**
1. Allows you to specify a fullPage.js version to update to
2. Updates the dependency and rebuilds
3. Creates a release and publishes to npm

## Complete Automated Flow

Here's how the full automation works:

```
Option 1: Daily Check
1. Daily Check (2 AM UTC)
   ↓
2. Check Latest fullPage.js workflow runs
   ↓
3. Checks both npm and GitHub for latest version
   ↓
4. If new version found → Creates PR
   ↓
5. You review and merge the PR
   ↓
6. Auto Update workflow triggers
   ↓
7. Builds, tests, and releases automatically

Option 2: Real-time from fullPage.js releases
1. New fullPage.js release published
   ↓
2. fullPage.js repository triggers repository dispatch
   ↓
3. Watch fullPage.js Releases workflow runs
   ↓
4. Creates PR immediately
   ↓
5. You review and merge the PR
   ↓
6. Auto Update workflow triggers
   ↓
7. Builds, tests, and releases automatically
```

## How It Gets the Latest Version

The system checks **multiple sources**:

1. **NPM Registry**: `npm view fullpage.js version`
2. **GitHub Releases**: `https://api.github.com/repos/alvarotrigo/fullPage.js/releases/latest`
3. **Repository Dispatch**: Direct notification from fullPage.js repository

This ensures we never miss an update, whether it's published to npm first or GitHub first.

## Setup Requirements

### 1. NPM Token
You need to add an NPM token to your repository secrets:

1. Go to your npm account settings
2. Generate a new access token
3. Add it to your GitHub repository secrets as `NPM_TOKEN`

### 2. Repository Permissions
Make sure the GitHub Actions have write permissions to:
- Create releases
- Push to the repository
- Publish to npm
- Create pull requests

### 3. Cross-Repository Communication (Optional)
To enable real-time updates from fullPage.js releases:

1. Generate a GitHub token with `repo` scope
2. Add it to the **fullPage.js repository** secrets as `REACT_FULLPAGE_TOKEN`
3. Add the `trigger-react-fullpage-update.yml` workflow to the fullPage.js repository

## How to Use

### Automatic Updates (Recommended)
1. The daily workflow will automatically check for fullPage.js updates
2. When a new version is found, it creates a PR
3. Review the PR and merge it
4. The auto-update workflow will trigger and create a release

### Real-time Updates (Optional)
1. Add the trigger workflow to the fullPage.js repository
2. When you publish a new fullPage.js release, it automatically triggers a PR in react-fullpage
3. Review and merge the PR
4. Auto-release happens automatically

### Manual Updates
1. Go to Actions tab in your repository
2. Select "Manual fullPage.js Update"
3. Click "Run workflow"
4. Enter the fullPage.js version you want to update to
5. Click "Run workflow"

### Manual Check for Updates
1. Go to Actions tab in your repository
2. Select "Check Latest fullPage.js"
3. Click "Run workflow"
4. This will check for updates and create a PR if needed

## Repository References

- **fullPage.js repository**: https://github.com/alvarotrigo/fullPage.js
- **Latest release**: https://github.com/alvarotrigo/fullPage.js/releases/latest
- **NPM package**: https://www.npmjs.com/package/fullpage.js

## Dependabot Configuration

The `.github/dependabot.yml` file is configured to:
- Check for npm updates daily
- Only create PRs for dependency updates
- Add appropriate labels and assignees

## Benefits

- **Always up-to-date**: Users get the latest fullPage.js versions
- **Multiple sources**: Checks both npm and GitHub for updates
- **Real-time**: Can be notified immediately when fullPage.js releases
- **Automated**: No manual intervention needed for patch/minor updates
- **Tested**: All updates go through the build and test process
- **Versioned**: Each update creates a new patch version
- **Documented**: Release notes are automatically generated
- **Proactive**: Actively checks for updates instead of waiting for Dependabot 