Skip to content

Remove unused assets #46

Remove unused assets

Remove unused assets #46

name: Remove unused assets
# **What it does**:
# **Why we have it**:
# **Who does it impact**:
on:
schedule:
- cron: '20 15 * * 0' # run every Sunday at 20:15 UTC / 12:15 PST
permissions:
contents: write
env:
FREEZE: ${{ secrets.FREEZE }}
jobs:
remove_unused_assets:
name: Remove unused assets
if: github.repository == 'github/docs-internal'
runs-on: ubuntu-latest
steps:
- if: ${{ env.FREEZE == 'true' }}
run: |
echo 'The repo is currently frozen! Exiting this workflow.'
exit 1 # prevents further steps from running
- name: Checkout
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
- name: Setup Node
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
with:
node-version: '16.15.0'
cache: npm
- name: npm ci
run: npm ci
- name: Run scripts
run: |
script/remove-unused-assets.js > results.md
- name: Get script results to use in PR body
id: results
uses: juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512
with:
path: ./results.md
- name: Remove script results file
run: rm ./results.md
- name: Create pull request
uses: peter-evans/create-pull-request@bd72e1b7922d417764d27d30768117ad7da78a0e
env:
# Disable pre-commit hooks; they don't play nicely here
HUSKY: '0'
with:
# need to use a token with repo and workflow scopes for this step
token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
commit-message: Action ran script/remove-unused-assets.js
title: Remove unused assets
body:
"Hello! This PR removes some files that exist in the repo but are not used in content or data files:\n\n
${{ steps.results.outputs.content }}
\n\nIf you have any questions, please contact @github/docs-engineering."
labels: unused assets
project: Core docs work for the current week
project-column: Should do
branch: remove-unused-assets
- if: ${{ failure() && env.FREEZE != 'true' }}
name: Delete remote branch (if previous steps failed)
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: remove-unused-assets