Skip to content

martincostello/update-static-assets

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Update Static Assets

Build status codecov OpenSSF Scorecard

This action updates static assets for HTML-related files stored in a GitHub repository.

An example pull request created by the action can be found here.

The following CDNs are supported:

Example Usage

steps:
- uses: actions/checkout@v3
- uses: martincostello/update-static-assets@v1
  with:
    repo-token: ${{ secrets.GITHUB_TOKEN }}

Example Workflow

Below is an example of a full GitHub Actions workflow to automate static asset updates.

name: update-static-assets

on:

  # Scheduled trigger to check for static asset updates once a day at 5AM
  schedule:
    - cron:  '0 5 * * *'

  # Manual trigger to update static assets on demand
  workflow_dispatch:

permissions:
  contents: read
  pull-requests: read

jobs:
  update-static-assets:
    name: Update static assets
    permissions:
      contents: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: martincostello/update-static-assets@v1
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}

Inputs

Required

Name Description
repo-token The GitHub access token to use to create a pull request for any updates to the repository.

Optional

Name Description Default
branch-name-prefix The optional Git branch name prefix to use. -
close-superseded If true, any existing pull requests superseded by any pull requests opened by the action are closed. true
commit-message The optional Git commit message to use. -
configuration-file The optional path to a configuration file to use (see configuration). .update-static-assets.json
file-extensions The optional comma-separated file extension(s) to search for static assets within. cshtml,html,razor
labels The optional comma-separated label(s) to apply to pull requests generated by the action. -
repo The optional GitHub repository to generate the pull request against. github.repository
repo-path The optional path of the repository to check for updates. .
user-email The optional email address to use for Git commits. github-actions[bot]@users.noreply.github.com
user-name The optional user name to use for Git commits. github-actions[bot]
dry-run If true, the action will not push changes to GitHub. false

Outputs

Name Description
assets-updated Whether any static assets were updated by the action.
pulls-closed A JSON array of the numbers of any pull requests that were closed as superseded.
pulls-opened A JSON array of the numbers of any pull requests that were opened to update static assets.

Configuration

Additional options can be specified with a JSON configuration file. The file's path can be specified with the configuration-file input.

To ignore updates for a specific asset, add an item to the ignore property of the configuration file specifying the asset CDN and name to ignore along with a Regular Expression that specifies the version(s) of the asset to ignore updates for.

An example configuration file is shown below.

{
    "ignore": [
        {
            "cdn": "cdnjs",
            "name": "bootstrap",
            "version": "6\\..*"
        }
    ]
}

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

Repository

The repository is hosted in GitHub: https://github.com/martincostello/update-static-assets.git

License

This project is licensed under the Apache 2.0 license.