-
-
Notifications
You must be signed in to change notification settings - Fork 11
125 lines (115 loc) · 4.21 KB
/
build.yml
File metadata and controls
125 lines (115 loc) · 4.21 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
name: "Build - API documentation"
on:
workflow_dispatch:
inputs:
developrun:
description: 'Develop run, true or false?'
required: true
default: 'true'
push:
branches:
- main
jobs:
build_docs:
name: BuildDocs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout website
uses: actions/checkout@v6
with:
path: 'api-docs'
repository: 'firefly-iii/api-docs'
token: ${{ secrets.GIT_REPOS_TOKEN }}
fetch-depth: 0
- id: ff3version
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: firefly-iii
repo: firefly-iii
excludes: prerelease, draft
token: ${{ secrets.GIT_REPOS_TOKEN }}
- name: Create or find branch
run: |
cd api-docs
RES=$(git ls-remote --heads origin ${{ steps.ff3version.outputs.release }})
if [[ $RES == '' ]]; then
echo "Git branch '${{ steps.ff3version.outputs.release }}' does not exist in the remote repository"
git checkout -b ${{ steps.ff3version.outputs.release }}
git push -u origin ${{ steps.ff3version.outputs.release }}
else
echo "Git branch '${{ steps.ff3version.outputs.release }}' already exists"
git checkout -b ${{ steps.ff3version.outputs.release }} origin/${{ steps.ff3version.outputs.release }}
fi
cd ..
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: >-
fileinfo
json
yaml
mbstring
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
- name: Build documentation
run: |
#
# Set some git things.
#
sudo timedatectl set-timezone Europe/Amsterdam
git config user.name github-actions
git config user.email github-actions@github.com
git config pull.rebase false
#
# Go to API docs and pull the necessary branch.
#
cd api-docs
git config user.name github-actions
git config user.email github-actions@github.com
git config pull.rebase false
# if develop run is true, only checkout main, not the branch.
if [[ "$DEV_RUN" == "true" ]]; then
echo 'Do a develop run of the API docs, check out main branch.'
git pull origin main
git checkout main
fi
if [[ "$DEV_RUN" == "true" ]]; then
echo "Do a normal run of the API docs, check out ${{ steps.ff3version.outputs.release }} branch"
git pull origin ${{ steps.ff3version.outputs.release }}
fi
cd ..
#
# Run the actual build script.
#
# if developrun is true, only checkout main, not the branch.
if [[ "$DEV_RUN" == "true" ]]; then
echo 'Do a develop run of the API docs, build develop.'
php build-api-docs.php develop
fi
if [[ "$DEV_RUN" == "false" ]]; then
echo "Do a normal run of the API docs, build ${{ steps.ff3version.outputs.release }}"
php build-api-docs.php ${{ steps.ff3version.outputs.release }}
fi
#
# Back to the repository and push the changes.
# also go back to the main branch.
#
cd api-docs
git config user.name github-actions
git config user.email github-actions@github.com
git config pull.rebase false
git pull origin main
git add dist/firefly-iii-*-v1.yaml
git add dist/index.html
git commit -m "🤖 Update API documentation for Firefly III"
git push
env:
API_DESTINATION: ./api-docs/dist
API_SERVER: https://demo.firefly-iii.org
API_SOURCE_ROOT: ./api-docs/src
DEV_RUN: ${{ inputs.developrun || 'true' }}