-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (108 loc) · 4.8 KB
/
continous_publishing_stable.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Continous Publishing (stable)
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout source of pushed tag
- name: checkout source branch
uses: actions/checkout@v2
# Sphinx builds html and pdf documentation
# sphinx build sets environment variables
# * SPHINX_BUILD_PDF: the file path of the pdf file build by sphinx
# * DOCUMENT_NAME: official name for the documention configured in the sphinx configuration file conf.py
# NOTE: all user configaration is done in the sphinx config so that this file can left unchanged
- name: build documentation pdf and html
uses: ammaraskar/[email protected]
with:
pre-build-command: "apt-get update -y && apt-get install -y graphviz git latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
build-command: "make html latexpdf BUILDDIR=build"
docs-folder: "."
# Publish website on github pages
- name: get env.GITHUB_PAGES_WEBSITE_URL and env.WEBSITE_SUBDIR
run: |
WEBSITE_SUBDIR="stable"
REPOSITORY_OWNER_SLASH_NAME="${{ github.repository }}"
REPOSITORY_OWNER="${{ github.repository_owner }}"
REPOSITORY_NAME=${REPOSITORY_OWNER_SLASH_NAME##*/}
GITHUB_PAGES_WEBSITE_URL="https://${REPOSITORY_OWNER}.github.io/${REPOSITORY_NAME}"
echo WEBSITE_SUBDIR=$WEBSITE_SUBDIR
echo "WEBSITE_SUBDIR=$WEBSITE_SUBDIR" >> $GITHUB_ENV
echo GITHUB_PAGES_WEBSITE_URL=$GITHUB_PAGES_WEBSITE_URL
echo "GITHUB_PAGES_WEBSITE_URL=$GITHUB_PAGES_WEBSITE_URL" >> $GITHUB_ENV
- name: Commit build html documentation to gh-pages branch checkout in gh-pages subdir
run: |
# clone gh-pages branch into
git clone "https://github.com/$GITHUB_REPOSITORY.git" --branch gh-pages --single-branch gh-pages
rsync -av --delete build/html/ gh-pages/$WEBSITE_SUBDIR/
cd gh-pages
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore that.
- name: Push changes in gh-pages branch to github
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
# Create release and upload pdf and zipped website to github releases page
- name: get env.CREATE_RELEASE
run: |
REF=${{ github.ref }}
TAG_NAME=${REF##*/}
echo "pushing a tag: $TAG_NAME"
URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}"
StatusCode=$(curl -o -I -L -s -w "%{http_code}" -X GET -G $URL)
echo $StatusCode
if [[ "$StatusCode" == 200 ]]; then
echo "This is tagged release: there exists as github release for this tag."
CREATE_RELEASE="no"
else
echo "This is a tag for which no github release exist."
CREATE_RELEASE="yes"
fi
echo CREATE_RELEASE=$CREATE_RELEASE
echo "CREATE_RELEASE=$CREATE_RELEASE" >> $GITHUB_ENV
- name: Create Release
if: env.CREATE_RELEASE == 'yes'
# https://github.com/actions/create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: 'Online you can also find [the latest stable documentation](${{ env.GITHUB_PAGES_WEBSITE_URL }}/${{ env.WEBSITE_SUBDIR }}/).'
draft: false
prerelease: false
- name: Create Web Release Asset
run: |
cd build/html/; zip -r ../../website.zip .; cd -
- name: Get Release Info to fetch upload_url
id: get_release_info
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release asset as pdf
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.SPHINX_BUILD_PDF }}
asset_name: ${{ env.DOCUMENT_NAME }}.pdf
asset_content_type: binary/octet-stream
- name: Upload release asset as zipped html website (.website.zip)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./website.zip
asset_name: ${{ env.DOCUMENT_NAME }}.website.zip
asset_content_type: application/zip