|
| 1 | +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples |
| 2 | +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help |
| 3 | +# Modifications: |
| 4 | +# - Allow more roles to trigger each PR command |
| 5 | +# - Document builds README.md from README.Rmd with devtools::build_readme() |
| 6 | +# - Include a doc-preview command (uses Netlify to preview the docs) |
| 7 | +on: |
| 8 | + issue_comment: |
| 9 | + types: [created] |
| 10 | + |
| 11 | +name: pr-commands.yaml |
| 12 | + |
| 13 | +permissions: read-all |
| 14 | + |
| 15 | +jobs: |
| 16 | + document: |
| 17 | + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} |
| 18 | + name: document |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - uses: r-lib/actions/pr-fetch@v2 |
| 28 | + with: |
| 29 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - uses: r-lib/actions/setup-r@v2 |
| 32 | + with: |
| 33 | + use-public-rspm: true |
| 34 | + |
| 35 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 36 | + with: |
| 37 | + extra-packages: any::roxygen2 |
| 38 | + needs: pr-document |
| 39 | + |
| 40 | + - name: Document |
| 41 | + run: roxygen2::roxygenise() |
| 42 | + shell: Rscript {0} |
| 43 | + |
| 44 | + - name: Build README.md from README.Rmd |
| 45 | + run: Rscript -e 'if (file.exists("README.Rmd")) devtools::build_readme()' |
| 46 | + |
| 47 | + - name: commit |
| 48 | + run: | |
| 49 | + git config --local user.name "$GITHUB_ACTOR" |
| 50 | + git config --local user.email "[email protected]" |
| 51 | + git add man/\* NAMESPACE |
| 52 | + git commit -m 'Document' |
| 53 | +
|
| 54 | + - uses: r-lib/actions/pr-push@v2 |
| 55 | + with: |
| 56 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + style: |
| 59 | + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} |
| 60 | + name: style |
| 61 | + runs-on: ubuntu-latest |
| 62 | + env: |
| 63 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + permissions: |
| 65 | + contents: write |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - uses: r-lib/actions/pr-fetch@v2 |
| 70 | + with: |
| 71 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + - uses: r-lib/actions/setup-r@v2 |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: install.packages("styler") |
| 77 | + shell: Rscript {0} |
| 78 | + |
| 79 | + - name: Style |
| 80 | + run: styler::style_pkg() |
| 81 | + shell: Rscript {0} |
| 82 | + |
| 83 | + - name: commit |
| 84 | + run: | |
| 85 | + git config --local user.name "$GITHUB_ACTOR" |
| 86 | + git config --local user.email "[email protected]" |
| 87 | + git add \*.R |
| 88 | + git commit -m 'Style' |
| 89 | +
|
| 90 | + - uses: r-lib/actions/pr-push@v2 |
| 91 | + with: |
| 92 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + |
| 94 | + preview: |
| 95 | + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/preview-docs') }} |
| 96 | + |
| 97 | + runs-on: ubuntu-latest |
| 98 | + permissions: |
| 99 | + # Needed to write a comment on the PR |
| 100 | + pull-requests: write |
| 101 | + # Needed to read the PR branch |
| 102 | + contents: read |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + with: |
| 106 | + # Checkout the PR branch |
| 107 | + ref: refs/pull/${{ github.event.issue.number }}/head |
| 108 | + |
| 109 | + - uses: r-lib/actions/setup-pandoc@v2 |
| 110 | + |
| 111 | + - uses: r-lib/actions/setup-r@v2 |
| 112 | + with: |
| 113 | + use-public-rspm: true |
| 114 | + |
| 115 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
| 116 | + with: |
| 117 | + extra-packages: any::pkgdown, local::. |
| 118 | + needs: website |
| 119 | + |
| 120 | + - name: Build site |
| 121 | + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) |
| 122 | + shell: Rscript {0} |
| 123 | + |
| 124 | + - name: Deploy to Netlify |
| 125 | + |
| 126 | + with: |
| 127 | + # Standard config |
| 128 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + deploy-message: "Deploy from GitHub Actions" |
| 130 | + # 'docs/' is the default directory for pkgdown::build_site() |
| 131 | + # we add 'dev' because _pkgdown.yml has 'development: mode: devel' |
| 132 | + publish-dir: './docs/dev' |
| 133 | + # Development deploys only |
| 134 | + production-deploy: false |
| 135 | + # Enable pull request comment (default) |
| 136 | + enable-pull-request-comment: true |
| 137 | + # Overwrite the pull request comment with updated link (default) |
| 138 | + overwrites-pull-request-comment: true |
| 139 | + # Don't deploy to GitHub |
| 140 | + enable-github-deployment: false |
| 141 | + # Don't update the status of the commit |
| 142 | + enable-commit-status: false |
| 143 | + # Don't comment on the commit |
| 144 | + enable-commit-comment: false |
| 145 | + env: |
| 146 | + # Netlify credentials (currently from Dmitry's account) |
| 147 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 148 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 149 | + timeout-minutes: 1 |
0 commit comments