Giter VIP home page Giter VIP logo

svgo-action's Introduction

SVGO Action

Build status Coverage Report Mutation Report Maintainability Snyk Status FOSSA Status

Automatically run SVGO with GitHub Actions.

Usage

Install the Action

Create a Workflow file (e.g.: .github/workflows/optimize.yml, see Creating a Workflow file) with the workflow below - or check out the examples for various complete workflows. You can also check what the Action does for each on event and what the Action outputs for subsequent steps.

name: Optimize
on:
# Comment the next line if you *don't* want the Action to run on Pull Requests.
  pull_request:
# Uncomment the next line if you want the Action to run on pushes.
#   push:
# Uncomment the next 2 lines if you want the Action to run on a schedule.
#   schedule:
#   - cron:  '0 * * * 1'  # See https://crontab.guru/
# Uncomment one of the next 2 lines if you want to manually trigger the Action.
#   repository_dispatch:
#   workflow_dispatch:

jobs:
  svgs:
    name: SVGs
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    # Uncomment the next 2 lines to select a branch for on schedule or dispatch.
    #   with:
    #     ref: main
    - uses: ericcornelissen/svgo-action@v3
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}

Note: This grants access to the GITHUB_TOKEN so the Action can make calls to GitHub's rest API. This is only needed for pull_request and push events.

Configure the Action

The following inputs are available when using the SVGO Action.

Name Description Default Documentation
dry-run Prevent the Action from writing changes false docs
ignore globs of SVGs that should be ignored "" docs
repo-token A GitHub token (secrets.GITHUB_TOKEN) "" docs
strict Fail on non-critical errors false docs
svgo-config The path of the SVGO configuration file "svgo.config.js" docs
svgo-version The version of SVGO to use 2 docs

To configure the Action you simply set a value for any of the above in the Workflow file. For example:

- uses: ericcornelissen/svgo-action@v3
  with:
    repo-token: ${{ secrets.GITHUB_TOKEN }}
    dry-run: true
    ignore: do/not/optimize/**/
    strict: false
    svgo-config: path/to/svgo-config.js
    svgo-version: 2

Advanced Usage

Limit Runs

Even though this Action won't do anything if a push or Pull Request does not touch any SVGs, you may want the Action to run only when an SVG has actually changed. To do this you can change the Workflow file that uses this Action to be triggered only when SVGs change. Update the value of pull_request and/or push as follows:

โš ๏ธ This will cause the entire Workflow to be run only when an SVG changes. Jobs that should run for every push or Pull Request must be specified in a separate Workflow file.

on:
  pull_request:
    paths:
    - "**.svg"
  push:
    paths:
    - "**.svg"

Token Permissions

The minimum required permissions needed to run this Action are:

permissions:
  contents: read
  # Uncomment the next line if you're using the Action on Pull Requests
  #   pull-requests: read

# Or use `read-all` to allow reading in all scopes (recommended for open source)
permissions: read-all

svgo-action's People

Contributors

ericcornelissen avatar renovate-bot avatar renovate[bot] avatar github-actions[bot] avatar dependabot[bot] avatar anubha13kumari avatar fossabot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.