xref: /dokuwiki/.github/workflows/deletedFiles.yml (revision 53c68e5c9a0b29a9c116db947e44703197894557)
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 on" line.
6# Finally, the list of newly removed entries receives a header "# removed on $(date -I)" with the current ISO date.
7
8name: "Update deleted files"
9on:
10  push:
11    branches:
12      - master
13
14jobs:
15  update:
16    name: Update deleted files
17    runs-on: ubuntu-latest
18    steps:
19      - name: Checkout
20        uses: actions/checkout@v4
21        with:
22          fetch-depth: 0
23
24      - name: Cleaning list from re-introduced files
25        run: |
26          for E in $(git ls-tree -r master --name-only); do
27            if (git check-attr export-ignore "$E" | grep -q "export-ignore: set"); then
28              continue
29            fi
30            grep -v "^$E$" data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
31          done
32
33      - name: Update list with deleted files
34        run: |
35          for F in $(git diff origin/stable..HEAD --summary | awk '/^ delete/ && $4 !~ /^(VERSION)/ {print $4}'); do
36            if (git check-attr export-ignore "$F" | grep -q "export-ignore: set"); then
37              continue
38            fi
39            if grep -q "^$F$" data/deleted.files; then
40              continue
41            fi
42            if ( ! test -f "data/deleted.files.tmp"); then
43              awk -v "input=# newly removed" '/# removed on/ && !found {print input; found=1} 1' data/deleted.files > data/deleted.files.tmp && cp data/deleted.files{.tmp,}
44            fi
45            awk -v "input=$F" '/# removed on/ && !found {print input; found=1} 1' data/deleted.files > data/deleted.files.tmp && cp data/deleted.files{.tmp,}
46          done
47          if (test -f "data/deleted.files.tmp"); then
48            awk '/# removed on/ && !found {printf("\n"); found=1} 1' data/deleted.files > data/deleted.files.tmp && mv data/deleted.files{.tmp,}
49            sed -i "s/^# newly removed/# removed on $(date -I)/" data/deleted.files
50          fi
51
52      - name: Create Pull Request
53        uses: peter-evans/create-pull-request@v6
54        with:
55          commit-message: "�� Update deleted files"
56          title: "�� Update deleted files"
57          body: "This updates the list of deleted files based on the recent changes."
58          delete-branch: true
59          branch: "bot/deletedFiles"
60