Skip to content

Commit 27ea7e3

Browse files
committed
ci: Publish docs, don't publish unless files edited
1 parent 5c6499a commit 27ea7e3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/publish-docs.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,38 @@ jobs:
3939

4040
- name: Set up Python ${{ matrix.python-version }}
4141
uses: actions/setup-python@v1
42+
if: env.PUBLISH == 'true'
4243
with:
4344
python-version: ${{ matrix.python-version }}
4445

4546
- name: Get full Python version
4647
id: full-python-version
4748
shell: bash
49+
if: env.PUBLISH == 'true'
4850
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
4951

5052
- name: Install poetry
53+
if: env.PUBLISH == 'true'
5154
run: |
5255
curl -O -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
5356
python get-poetry.py -y --version 1.0.10
5457
echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
5558
rm get-poetry.py
5659
5760
- name: Get poetry cache paths from config
61+
if: env.PUBLISH == 'true'
5862
run: |
5963
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
6064
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
6165
6266
- name: Configure poetry
6367
shell: bash
68+
if: env.PUBLISH == 'true'
6469
run: poetry config virtualenvs.in-project true
6570

6671
- name: Set up cache
6772
uses: actions/cache@v2
73+
if: env.PUBLISH == 'true'
6874
id: cache
6975
with:
7076
path: |
@@ -74,23 +80,28 @@ jobs:
7480
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
7581

7682
- name: Ensure cache is healthy
77-
if: steps.cache.outputs.cache-hit == 'true'
83+
if: steps.cache.outputs.cache-hit == 'true' && env.PUBLISH == 'true'
7884
shell: bash
7985
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
8086

8187
- name: Upgrade pip
8288
shell: bash
89+
if: env.PUBLISH == 'true'
8390
run: poetry run python -m pip install pip -U
8491

8592
- name: Install dependencies [w/ docs]
93+
if: env.PUBLISH == 'true'
8694
run: poetry install --extras "docs lint"
8795

8896
- name: Build documentation
97+
if: env.PUBLISH == 'true'
98+
if: env.PUBLISH == 'true'
8999
run: |
90100
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd
91101
92102
- name: Push documentation to S3
93103
uses: jakejarvis/s3-sync-action@master
104+
if: env.PUBLISH == 'true'
94105
with:
95106
args: --acl public-read --follow-symlinks --delete
96107
env:
@@ -101,6 +112,7 @@ jobs:
101112
SOURCE_DIR: "docs/_build/html" # optional: defaults to entire repository
102113

103114
- name: Generate list of changed files for CloudFront to invalidate
115+
if: env.PUBLISH == 'true'
104116
run: |
105117
pushd docs/_build/html; FILES=$(find . -name \* -print | grep html | cut -c2- | sort | uniq | tr '\n' ' '); popd
106118
for file in $FILES; do
@@ -111,6 +123,7 @@ jobs:
111123
112124
- name: Invalidate on CloudFront
113125
uses: chetan/invalidate-cloudfront-action@master
126+
if: env.PUBLISH == 'true'
114127
env:
115128
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
116129
AWS_REGION: "us-east-1"

0 commit comments

Comments
 (0)