Repository navigation
108 lines (98 loc) · 3.43 KB
/
Copy pathcleanup.yml
File metadata and controls
108 lines (98 loc) · 3.43 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: 'Cleanup PHP Releases'
permissions:
contents: write
on:
workflow_dispatch:
inputs:
php-versions:
description: 'PHP versions to cleanup'
default: '8.2 8.3 8.4 8.5'
required: true
jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
php_matrix: ${{ steps.set-matrix.outputs.php_matrix }}
steps:
- name: Get matrix
id: set-matrix
run: |
IFS=' ' read -r -a PHP_VERSIONS <<<"${{ inputs.php-versions || '8.2 8.3 8.4 8.5' }}"
php_array=()
for php in "${PHP_VERSIONS[@]}"; do
php_array+=("{\"php\": \"$php\"}")
done
echo "php_matrix={\"include\":[$(echo "${php_array[@]}" | sed -e 's|} {|}, {|g')]}"
echo "php_matrix={\"include\":[$(echo "${php_array[@]}" | sed -e 's|} {|}, {|g')]}" >> "$GITHUB_OUTPUT"
cleanup-preview:
needs: get-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.get-matrix.outputs.php_matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Find cleanup candidates
run: bash scripts/release_cleanup_preview.sh cleanup-assets-${{ matrix.php }}.tsv
env:
GITHUB_RELEASES: php${{ matrix.php }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload cleanup list
uses: actions/upload-artifact@v7
with:
name: cleanup-assets-${{ matrix.php }}
path: cleanup-assets-${{ matrix.php }}.tsv
get-cleanup-matrix:
needs: cleanup-preview
runs-on: ubuntu-latest
outputs:
cleanup_matrix: ${{ steps.set-cleanup-matrix.outputs.cleanup_matrix }}
steps:
- name: Download cleanup lists
continue-on-error: true
uses: actions/download-artifact@v8
with:
pattern: cleanup-assets-*
path: cleanup-lists
merge-multiple: true
- name: Build cleanup matrix
id: set-cleanup-matrix
run: |
mkdir -p cleanup-lists
shopt -s nullglob
cleanup_array=()
for file in cleanup-lists/cleanup-assets-*.tsv; do
if [[ -s "$file" ]]; then
version=$(basename "$file")
version=${version#cleanup-assets-}
version=${version%.tsv}
cleanup_array+=("{\"php\": \"$version\"}")
fi
done
if (( ${#cleanup_array[@]} == 0 )); then
cleanup_matrix='{"include":[]}'
else
cleanup_matrix="{\"include\":[$(echo "${cleanup_array[@]}" | sed -e 's|} {|}, {|g')]}"
fi
echo "cleanup_matrix=$cleanup_matrix"
echo "cleanup_matrix=$cleanup_matrix" >> "$GITHUB_OUTPUT"
cleanup-apply:
if: needs.get-cleanup-matrix.outputs.cleanup_matrix != '{"include":[]}'
needs: get-cleanup-matrix
runs-on: ubuntu-latest
environment: release-cleanup
strategy:
matrix: ${{fromJson(needs.get-cleanup-matrix.outputs.cleanup_matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download cleanup list
uses: actions/download-artifact@v8
with:
name: cleanup-assets-${{ matrix.php }}
- name: Delete cleanup candidates
run: bash scripts/release_cleanup_apply.sh cleanup-assets-${{ matrix.php }}.tsv
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}