-
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (122 loc) · 5.58 KB
/
reports.yml
File metadata and controls
145 lines (122 loc) · 5.58 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Generate Reports and Deploy to GitHub Pages
on:
workflow_call:
workflow_dispatch:
pull_request:
types: [ "opened", "synchronize", "reopened", "closed" ]
push:
branches: [ "main" ]
permissions:
contents: write
pull-requests: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
reports:
if: github.event_name != 'pull_request' || github.event.action != 'closed'
name: Generate Reports
runs-on: ubuntu-latest
env:
PAGES_ARTIFACT_NAME: ${{ github.event_name == 'pull_request' && format('github-pages-pr-{0}', github.event.pull_request.number) || 'github-pages' }}
REPORTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: pcov, pcntl
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
COMPOSER_CACHE_DIR: /tmp/composer-cache
COMPOSER_ROOT_VERSION: ${{ env.REPORTS_ROOT_VERSION }}
run: composer install --prefer-dist --no-progress --no-interaction --no-scripts
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Generate reports
env:
COMPOSER_ROOT_VERSION: ${{ env.REPORTS_ROOT_VERSION }}
run: composer dev-tools reports -- --target=tmp/reports --coverage=tmp/reports/coverage
- name: Fix permissions
run: |
chmod -c -R +rX "tmp/reports/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Add .nojekyll
run: touch tmp/reports/.nojekyll
- name: Restore previews from gh-pages
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@v6
continue-on-error: true
with:
ref: gh-pages
path: gh-pages-current
- name: Copy existing previews into publish directory
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
if [ -d "gh-pages-current/previews" ]; then
mkdir -p tmp/reports/previews
cp -R gh-pages-current/previews/. tmp/reports/previews/
fi
- name: Deploy main reports
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./tmp/reports/
destination_dir: .
keep_files: false
force_orphan: false
- name: Deploy PR preview
if: github.event_name == 'pull_request'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./tmp/reports/
destination_dir: previews/pr-${{ github.event.pull_request.number }}
keep_files: false
force_orphan: false
- name: Comment preview URLs on pull request
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
message: |
🚀 Preview is available for this pull request.
- Docs: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/
- Coverage: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/coverage/
cleanup_preview:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
name: Cleanup Pull Request Preview
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages
uses: actions/checkout@v6
with:
ref: gh-pages
path: gh-pages
- name: Remove preview directory
run: |
rm -rf "gh-pages/previews/pr-${{ github.event.pull_request.number }}"
cd gh-pages
touch .nojekyll
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git diff --cached --quiet || git commit -m "chore: remove preview for PR #${{ github.event.pull_request.number }}"
- name: Push changes
run: |
cd gh-pages
git push