Skip to content

Commit

Permalink
wf: only manage PR use case for now
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouffard committed Nov 17, 2022
1 parent 7961f2d commit 7267bf4
Showing 1 changed file with 47 additions and 23 deletions.
70 changes: 47 additions & 23 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,41 @@ on:
- 'DESCRIPTION'
- 'README.md' # TODO use the right file, the repo from the repo cannot be included (wrong format, too much info)
jobs:
generate:
if: github.event.action != 'closed' # on PR closed, only teardown the surge deployment
# for Pull Request
# TODO manage close pr for surge teardown if: github.event.action != 'closed'
pr_preview:
# TODO test Ubuntu 22
runs-on: ubuntu-20.04
permissions:
pull-requests: write # surge-preview: PR comments
steps:
- uses: actions/checkout@v3

# TODO the following is duplicated with the R-CMD-check.yaml workflow
- uses: r-lib/actions/setup-r@v2
# default r version: release
# with:
# use-public-rspm: true
# r-version: ${{ matrix.config.r }}
# default r version: release
# with:
# use-public-rspm: true
# r-version: ${{ matrix.config.r }}
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website
- uses: r-lib/actions/setup-tinytex@v2
- uses: r-lib/actions/setup-pandoc@v2
# end of duplication
- name: Install package
run: R CMD INSTALL .
- name: Build website
shell: Rscript {0}
run: |
pkgdown::build_site()
# TODO only if we cannot publish to surge
- name: Upload
uses: actions/upload-artifact@v3
with:
name: documentation-${{github.sha}}
path: docs

publish_preview:
# on PR close, the 'generate' dependent job is skipped. So, without adding extra 'if' conditions, the job would be skipped as well
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-not-requiring-successful-dependent-jobs
# TODO the following is NOT WORKING!!
# if: github.event_name == 'pull_request' && (needs.generate.result == 'success' || needs.generate.result == 'skipped')
if: github.event_name == 'pull_request' && always()
runs-on: ubuntu-20.04
needs: generate
permissions:
pull-requests: write # surge-preview: PR comments
steps:
- name: Download documentation
if: github.event.action != 'closed'
uses: actions/download-artifact@v3
with:
name: documentation-${{github.sha}}
- uses: bonitasoft/actions/packages/surge-preview-tools@v1
id: surge-preview-tools
with:
Expand All @@ -76,3 +66,37 @@ jobs:
failOnError: true
teardown: 'true'
build: echo 'already built!'

# generate:
# if: github.event.action != 'closed' # on PR closed, only teardown the surge deployment
#
# publish_preview:
# # on PR close, the 'generate' dependent job is skipped. So, without adding extra 'if' conditions, the job would be skipped as well
# # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-not-requiring-successful-dependent-jobs
# # TODO the following is NOT WORKING!!
## if: github.event_name == 'pull_request' && (needs.generate.result == 'success' || needs.generate.result == 'skipped')
# if: github.event_name == 'pull_request' && always()
# runs-on: ubuntu-20.04
# needs: generate
# permissions:
# pull-requests: write # surge-preview: PR comments
# steps:
# - name: Download documentation
# if: github.event.action != 'closed'
# uses: actions/download-artifact@v3
# with:
# name: documentation-${{github.sha}}
# - uses: bonitasoft/actions/packages/surge-preview-tools@v1
# id: surge-preview-tools
# with:
# surge-token: ${{ secrets.SURGE_TOKEN }}
# - name: Manage surge preview
# if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
# uses: afc163/surge-preview@v1
# with:
# surge_token: ${{ secrets.GITHUB_TOKEN }}
# github_token: ${{ secrets.SURGE_TOKEN }}
# dist: ./docs
# failOnError: true
# teardown: 'true'
# build: echo 'already built!'

0 comments on commit 7267bf4

Please sign in to comment.