1.1.11 • Published 9 months ago

links-updater v1.1.11

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Releases Cla

Link Updater

A GitHub Action to automatically update links across your repository files. Perfect for maintaining documentation, updating deprecated URLs, or managing repository-wide link changes.

Features

  • 🔄 Automatically updates URLs across multiple files and directories
  • ⚙️ Configurable through YAML file
  • 📁 Supports multiple file types (md, html, etc.)
  • 🎯 Selective path processing
  • ⛔ Link ignore list support
  • 🔑 Template and environment variable support
  • 📝 Detailed logging and error reporting

Quick Start

  1. Create a workflow file .github/workflows/link-updater.yml:
name: Update Repository Links
on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  update-links:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4.2.2
        with:
          fetch-depth: 0

      - uses: iamvikshan/link-updater@v1.1.11
        with:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

Action Inputs

InputRequiredDefaultDescription
GITHUB_TOKENNogithub.tokenGitHub token for repository access
CONFIG_PATHNo.github/links-config.ymlPath to configuration file

Configuration Options

  1. Create a configuration file .github/links-config.yml The configuration file (default: .github/links-config.yml) supports the following options:
# Directories/files to process
# if not specified, the action will process all files in the repository
paths:
  - 'docs'
  - 'src/components'
  - '.'

# File patterns to include
# if both paths and files are not specified, the action will process all files in the repository
# if only paths are specified, the action will process all files in the specified directories
files:
  - '*.md'
  - 'README'
# Custom link and keyword replacements
# optional only if githubUrls is specified
links:
  - old: 'https://old-domain.com/docs'
    new: 'https://new-domain.com/documentation'
  - old: 'https://discord.gg/oldlink'
    new: 'https://discord.gg/newlink'
  # one word only, else it will be treated as a link
  - old: 'oldkeyword'
    new: 'newkeyword'

# Links/patterns to ignore
# optional, defaults 'node_modules'
ignore:
  - 'node_modules'
  - '*.test.ts'
  - 'https://keep-this-link.com'

!IMPORTANT

links cannot be empty if githubUrls is not specified

Advanced Usage

Using GitHub Context Variables

You can use GitHub context variables in your configuration:

links:
  - old: 'https://github.com/old/repo'
    new: ${{ github.repository }}
  - old: 'https://example.com/docs'
    new: ${{ secrets.NEW_DOCS_URL }}

# Automatic GitHub URL processing
githubUrls:
  types:
    - 'username' # Will update any github.com/username references and only those, not the repo or sponsors
    - 'repo' # Will update any github.com/username/repo references
    - 'sponsors' # Will update any github.com/sponsors/username references
    # - 'all'     # Uncomment to update all GitHub URLs

Multiple File Type Processing

Process different file types with specific patterns:

files:
  - 'README' # Simple filename
  - 'config.yml' # Filename with extension
  - '*.md' # All markdown files

Selective Path Processing

Choose specific directories or files to process:

paths:
  - '.' # Process entire repository
  - 'docs' # Process entire docs directory
  - 'src/components' # Process specific subdirectory
  - 'README.md' # Process specific file
  - 'docs/index.html' # Specific file in a directory

Whether to Create a Pull Request

# Create PR instead of direct commits
# optional, default `false`
createPr: true

Custom commit message

# optional, defaults 'chore: update repository links and keywords[skip ci]'
commitMsg: 'chore: update repository links and references[skip ci]'

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any problems or have questions, please open an issue in the repository.

Security

This action requires a GH_TOKEN with write permissions to update repository files. The token can be automatically provided by GitHub Actions but needs to be explicitly passed to the action.

permissions:
  contents: write
  pull-requests: write

For security best practices:

  • Only grant the minimum required permissions
  • Be careful when using custom configuration files
  • Review the link replacement patterns before deployment

Acknowledgments

This action was inspired by the need to maintain consistent documentation and links across repositories. You can say i am lazy but after forking repositories, i have to update the links in the README.md file and i thought why not automate this process. So here it is.

Alt

1.1.11

9 months ago

1.1.10

9 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago