@@ -2,9 +2,11 @@ name: Deploy gh-pages branch to GitHub Pages
2
2
3
3
on :
4
4
push :
5
- branches : ["gh-pages"]
6
-
7
- # Allows us to run this workflow manually from the Actions tab
5
+ branches :
6
+ - " gh-pages"
7
+ # Do a dry-run (update, no deploy) for PRs.
8
+ pull_request :
9
+ # Allow running this workflow manually from the Actions tab.
8
10
workflow_dispatch :
9
11
10
12
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -20,23 +22,44 @@ concurrency:
20
22
cancel-in-progress : false
21
23
22
24
jobs :
23
- deploy :
24
- environment :
25
- name : github-pages
26
- url : ${{ steps.deployment.outputs.page_url }}
25
+ build :
26
+ # Don't run on forks.
27
+ if : github.repository == 'PHPCSStandards/PHP_CodeSniffer'
27
28
runs-on : ubuntu-latest
28
29
steps :
29
- - name : Checkout
30
+ # By default use the `gh-pages` branch.
31
+ # For testing changes to the workflow or the scripts, use the PR branch
32
+ # to have access to the latest version of the workflow/scripts.
33
+ - name : Determine branch to use
34
+ id : base_branch
35
+ env :
36
+ REF : ${{ github.ref }}
37
+ run : |
38
+ if [ "${{ github.event_name }}" == "pull_request" ]; then
39
+ echo "BRANCH=$REF" >> "$GITHUB_OUTPUT"
40
+ else
41
+ echo 'BRANCH=gh-pages' >> "$GITHUB_OUTPUT"
42
+ fi
43
+
44
+ - name : Checkout code
30
45
uses : actions/checkout@v4
46
+ with :
47
+ ref : ${{ steps.base_branch.outputs.BRANCH }}
31
48
32
49
- name : Install PHP
33
- run : |
34
- sudo apt-get update
35
- sudo apt-get install -y php
50
+ uses : shivammathur/setup-php@v2
51
+ with :
52
+ php-version : ' 8.4'
53
+ ini-values : error_reporting=-1, display_errors=On, log_errors_max_len=0
54
+ coverage : none
36
55
37
56
- name : Generate /phars/index.html
38
- run : |
39
- php build/generate_phars_list.php
57
+ run : php build/generate_phars_list.php
58
+
59
+ - name : Check GitHub Pages status
60
+ uses : crazy-max/ghaction-github-status@v4
61
+ with :
62
+ pages_threshold : major_outage
40
63
41
64
- name : Setup Pages
42
65
uses : actions/configure-pages@v5
45
68
uses : actions/upload-pages-artifact@v3
46
69
with :
47
70
path : ' ./src'
71
+
72
+ deploy :
73
+ needs : build
74
+ # Don't run on forks.
75
+ if : github.repository == 'PHPCSStandards/PHP_CodeSniffer' && github.event_name != 'pull_request' && needs.build.result == 'success'
48
76
77
+ name : " Deploy the website"
78
+ runs-on : ubuntu-latest
79
+
80
+ environment :
81
+ name : github-pages
82
+ url : ${{ steps.deployment.outputs.page_url }}
83
+
84
+ steps :
49
85
- name : Deploy to GitHub Pages
50
86
id : deployment
51
87
uses : actions/deploy-pages@v4
88
+
0 commit comments