forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 2.27 KB
/
dont-delete-assets.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Don't delete assets
# **What it does**:
# If the PR (against main) involves deletion of assets, if any of
# them are deletions or renames, post a comment, and ultimately
# fail the check.
# **Why we have it**:
# If you delete the reference to an image, the English content is fine
# because it no longer tries to serve an image that doesn't exist.
# But this is not the case for translations.
# **Who does it impact**: Docs content.
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'assets/**'
- '.github/workflows/dont-delete-assets.yml'
permissions:
contents: read
pull-requests: write
jobs:
dont-delete-assets:
# It's 'docs-bot' that creates those PR from "Delete orphaned assets"
if: github.event.pull_request.user.login != 'docs-bot' && (github.repository == 'github/docs-internal' || github.repository == 'github/docs')
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/node-npm-setup
- name: Get comment markdown
id: comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run deleted-assets-pr-comment
- name: Find possible previous comment
if: ${{ steps.comment.outputs.markdown != '' }}
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e
id: findComment
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- DELETED_ASSETS -->'
- name: Update comment
if: ${{ steps.comment.outputs.markdown != '' }}
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
with:
comment-id: ${{ steps.findComment.outputs.comment-id }}
issue-number: ${{ github.event.number }}
body: ${{ steps.comment.outputs.markdown }}
edit-mode: replace
- name: Ultimately fail the workflow for attention
if: ${{ steps.comment.outputs.markdown != '' }}
run: |
echo "More than 1 asset image was deleted as part of this PR."
echo "See posted PR commented about how to get them back."
exit 1