Skip to content

Commit c7d914c

Browse files
committed
ci: Publish docs, don't publish unless files edited
1 parent e641789 commit c7d914c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/publish-docs.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ 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/install-poetry.py
5356
python install-poetry.py -y --version 1.1.7
@@ -56,18 +59,22 @@ jobs:
5659
5760
- name: Add ~/.local/bin to PATH
5861
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
62+
if: env.PUBLISH == 'true'
5963

6064
- name: Get poetry cache paths from config
65+
if: env.PUBLISH == 'true'
6166
run: |
6267
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
6368
echo "poetry_virtualenvs_path=$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^\"//' -e 's/\"$//')" >> $GITHUB_ENV
6469
6570
- name: Configure poetry
6671
shell: bash
72+
if: env.PUBLISH == 'true'
6773
run: poetry config virtualenvs.in-project true
6874

6975
- name: Set up cache
7076
uses: actions/cache@v2
77+
if: env.PUBLISH == 'true'
7178
id: cache
7279
with:
7380
path: |
@@ -77,23 +84,28 @@ jobs:
7784
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
7885

7986
- name: Ensure cache is healthy
80-
if: steps.cache.outputs.cache-hit == 'true'
87+
if: steps.cache.outputs.cache-hit == 'true' && env.PUBLISH == 'true'
8188
shell: bash
8289
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
8390

8491
- name: Upgrade pip
8592
shell: bash
93+
if: env.PUBLISH == 'true'
8694
run: poetry run python -m pip install pip -U
8795

8896
- name: Install dependencies [w/ docs]
97+
if: env.PUBLISH == 'true'
8998
run: poetry install --extras "docs lint"
9099

91100
- name: Build documentation
101+
if: env.PUBLISH == 'true'
102+
if: env.PUBLISH == 'true'
92103
run: |
93104
pushd docs; make SPHINXBUILD='poetry run sphinx-build' html; popd
94105
95106
- name: Push documentation to S3
96107
uses: jakejarvis/s3-sync-action@master
108+
if: env.PUBLISH == 'true'
97109
with:
98110
args: --acl public-read --follow-symlinks --delete
99111
env:
@@ -104,6 +116,7 @@ jobs:
104116
SOURCE_DIR: "docs/_build/html" # optional: defaults to entire repository
105117

106118
- name: Generate list of changed files for CloudFront to invalidate
119+
if: env.PUBLISH == 'true'
107120
run: |
108121
pushd docs/_build/html; FILES=$(find . -name \* -print | grep html | cut -c2- | sort | uniq | tr '\n' ' '); popd
109122
for file in $FILES; do
@@ -114,6 +127,7 @@ jobs:
114127
115128
- name: Invalidate on CloudFront
116129
uses: chetan/invalidate-cloudfront-action@master
130+
if: env.PUBLISH == 'true'
117131
env:
118132
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
119133
AWS_REGION: "us-east-1"

0 commit comments

Comments
 (0)