Remove unused assets #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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@1e204e9a9253d643386038d443f96446fa156a97 | |
- name: Setup Node | |
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c | |
with: | |
node-version: 16.13.x | |
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 -rf ./results.md | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad | |
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 |