Repository navigation
Repo sync #749
This file contains hidden or 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: Don't delete assets | |
| # Fails asset-deletion PRs because translations still reference deleted English assets. | |
| # The comment script exempts generated copilot-sdk assets that sync pipelines recreate. | |
| 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: | |
| # The Orphaned files check workflow opens docs-bot PRs that delete assets on purpose. | |
| 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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - 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@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad | |
| 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 != '' }} | |
| # Fork PRs get a read-only token, so posting fails there. The next step still shows the instructions. | |
| continue-on-error: true | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 | |
| 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 != '' }} | |
| env: | |
| MARKDOWN: ${{ steps.comment.outputs.markdown }} | |
| run: | | |
| echo "More than 1 asset image was deleted as part of this PR." | |
| echo "See the PR comment or this job's summary for how to get them back." | |
| echo "$MARKDOWN" >> "$GITHUB_STEP_SUMMARY" | |
| echo "$MARKDOWN" | |
| exit 1 |