1
0
mirror of synced 2026-01-06 06:02:35 -05:00

Update orphaned assets workflow for use with translation repos (#31869)

This commit is contained in:
Hector Alfaro
2022-10-24 11:37:17 -04:00
committed by GitHub
parent 1be0cd7033
commit 9eb0c2c0e1
6 changed files with 36 additions and 585 deletions

View File

@@ -17,13 +17,46 @@ jobs:
if: ${{ github.repository == 'github/docs-internal' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout English repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
# Using a PAT is necessary so that the new commit will trigger the
# CI in the PR. (Events from GITHUB_TOKEN don't trigger new workflows.)
token: ${{ secrets.DOCUBOT_REPO_PAT }}
# TODO: Can be removed after we no longer keep translations in-repo
- name: Remove existing language translations
run: |
rm -rf translations
- name: Checkout the es-es repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
repository: github/docs-internal.es-es
token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
path: translations/es-ES
- name: Checkout the pt-br repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
repository: github/docs-internal.pt-br
token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
path: translations/pt-BR
- name: Checkout the zh-cn repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
repository: github/docs-internal.zh-cn
token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
path: translations/zh-CN
- name: Checkout the ja-jp repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
repository: github/docs-internal.ja-jp
token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
path: translations/ja-JP
- name: Setup node
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
with:
@@ -43,7 +76,7 @@ jobs:
./script/find-orphaned-assets.js | xargs git rm
# If nothing to commit, exit now. It's fine. No orphans.
git status | grep 'nothing to commit' && exit 0
git status -- ':!translations*' | grep 'nothing to commit' && exit 0
# Replicated from the translation pipeline PR-maker Action
git config --global user.name "docubot"

View File

@@ -1,69 +0,0 @@
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.17.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