xref: /dokuwiki/.github/workflows/deletedFiles.yml (revision 3d8dbb19b9ef9d8d24140fe79706d7ec734aaa9d)
1# This workflow updates the list of deleted files based on the recent changes and creates a pull request.
2# It compares the current master with the data/deleted.files file and cleans the file from any re-introduced files.
3# It compares the current master with the stable branch and adds all deleted files to the data/deleted.files file
4# unless they are already listed there or are excluded from the release archives (export-ignore in .gitattributes).
5# Any additions are made to the top of the list with a single trailing line before the first "# removed in" line.
6
7name: "Update deleted files"
8on:
9  push:
10    branches:
11      - master
12
13jobs:
14  update:
15    name: Update deleted files
16    runs-on: ubuntu-latest
17    steps:
18      - name: Checkout
19        uses: actions/checkout@v4
20        with:
21          fetch-depth: 0
22
23      - name: Cleaning list from re-introduced files
24        run: |
25          for E in $(git ls-tree -r master --name-only); do
26            if (git check-attr export-ignore "$E" | grep -q "export-ignore: set"); then
27              continue
28            fi
29            grep -v "^$E$" data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
30          done
31
32      - name: Update list with deleted files
33        run: |
34          for F in $(git diff origin/stable..HEAD --summary | awk '/^ delete/ && $4 !~ /^(VERSION)/ {print $4}'); do
35            if (git check-attr export-ignore "$F" | grep -q "export-ignore: set"); then
36              continue
37            fi
38            if grep -q "^$F$" data/deleted.files; then
39              continue
40            fi
41            awk -v "input=$F" '/# removed in/ && !found {print input; found=1} 1' data/deleted.files > data/deleted.files.tmp && cp data/deleted.files{.tmp,}
42          done
43          if (test -f "data/deleted.files.tmp"); then
44            awk '/# removed in/ && !found {printf("\n"); found=1} 1' data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
45          fi
46
47      - name: Create Pull Request
48        uses: peter-evans/create-pull-request@v4
49        with:
50          commit-message: "�� Update deleted files"
51          title: "�� Update deleted files"
52          body: "This updates the list of deleted files based on the recent changes."
53          delete-branch: true
54          branch: "bot/deletedFiles"
55