-
-
Notifications
You must be signed in to change notification settings - Fork 6
103 lines (92 loc) · 3.34 KB
/
update-website.yml
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
name: Build website
on:
# Trigger the workflow whenever a new tag is created.
push:
branches:
- 'stable'
tags:
- '**'
# And whenever this workflow or one of the associated scripts is updated (for a dry-run).
pull_request:
branches-ignore:
- 'stable'
paths:
- 'README.md'
- '.github/workflows/update-website.yml'
- '.github/build/**'
# Also allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: "Update website files"
# Don't run on forks.
if: github.repository == 'PHPCSStandards/PHPCSDevTools'
runs-on: ubuntu-latest
steps:
# By default use the `stable` branch as the published docs should always
# reflect the latest release.
# For testing changes to the workflow or the scripts, use the PR branch
# to have access to the latest version of the workflow/scripts.
- name: Determine branch to use
id: base_branch
env:
REF: ${{ github.ref }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH=$REF" >> $GITHUB_OUTPUT
else
echo 'BRANCH=stable' >> $GITHUB_OUTPUT
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ steps.base_branch.outputs.BRANCH }}
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
coverage: none
- name: Prepare the files which will be deployed to the GH Pages website
run: php .github/build/update-website.php
- name: "Set variable: short sha"
id: set_sha
env:
SHA: ${{ github.sha }}
run: |
shortsha=$(echo "$SHA" | cut -b 1-6)
echo "SHORTSHA=$shortsha" >> $GITHUB_OUTPUT
- name: Prepare commit message
id: commit_msg
env:
REF_NAME: ${{ github.ref_name }}
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref_type }}" == 'tag' ]]; then
echo "MSG=Update website for release of version $REF_NAME" >> $GITHUB_OUTPUT
else
echo "MSG=Sync website after commit (sha: ${{ steps.set_sha.outputs.SHORTSHA }})" >> $GITHUB_OUTPUT
fi
- name: Check GitHub Pages status
uses: crazy-max/ghaction-github-status@v3
with:
pages_threshold: major_outage
- name: Deploy the website
if: success()
uses: crazy-max/ghaction-github-pages@v4
with:
build_dir: 'deploy'
target_branch: 'gh-pages'
keep_history: true
#allow_empty_commit: false # Turn on after verification that it all works as expected.
jekyll: true
commit_message: ${{ steps.commit_msg.outputs.MSG }}
dry_run: ${{ steps.base_branch.outputs.BRANCH != 'stable' }}
verbose: ${{ matrix.verbose }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}