|
| 1 | +# Workflow based on https://github.com/r-lib/actions/blob/master/examples/pkgdown.yaml |
| 2 | + |
| 3 | +name: CI deploy documentation (dev) |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + workflow_dispatch: |
| 10 | + release: |
| 11 | + types: |
| 12 | + - published |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-20.04 |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + persist-credentials: false |
| 22 | + - name: Install SSH Client |
| 23 | + uses: webfactory/ssh-agent@v0.7.0 |
| 24 | + with: |
| 25 | + ssh-private-key: ${{ secrets.DEPLOY_KEY }} |
| 26 | + |
| 27 | + - name: Install R |
| 28 | + uses: r-lib/actions/setup-r@v2 |
| 29 | + with: |
| 30 | + r-version: 'release' |
| 31 | + |
| 32 | + - uses: r-lib/actions/setup-pandoc@v2 |
| 33 | + |
| 34 | + - name: Query dependencies |
| 35 | + run: | |
| 36 | + install.packages('remotes') |
| 37 | + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
| 38 | + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 39 | + shell: Rscript {0} |
| 40 | + |
| 41 | + - name: Cache R packages |
| 42 | + uses: actions/cache@v3 |
| 43 | + with: |
| 44 | + path: ${{ env.R_LIBS_USER }} |
| 45 | + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
| 46 | + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
| 47 | + |
| 48 | + - name: Install system dependencies package |
| 49 | + run: | |
| 50 | + while read -r cmd |
| 51 | + do |
| 52 | + eval sudo $cmd |
| 53 | + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') |
| 54 | +
|
| 55 | + - name: Install system dependencies pkgdown |
| 56 | + run: | |
| 57 | + while read -r cmd |
| 58 | + do |
| 59 | + eval sudo $cmd |
| 60 | + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04", package="pkgdown"))') |
| 61 | +
|
| 62 | + - name: Install additional system dependencies for pkgdown |
| 63 | + run: sudo apt-get install libharfbuzz-dev libfribidi-dev |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + run: | |
| 67 | + remotes::install_deps(dependencies = TRUE) |
| 68 | + remotes::install_cran("pkgdown") |
| 69 | + shell: Rscript {0} |
| 70 | + |
| 71 | + - name: Install package |
| 72 | + run: R CMD INSTALL . |
| 73 | + |
| 74 | + - name: Build docu with pkgdown |
| 75 | + run: Rscript -e 'pkgdown::build_site(new_process = FALSE)' |
| 76 | + |
| 77 | + - name: Deploy to dev |
| 78 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }} |
| 79 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 80 | + with: |
| 81 | + repository-name: DoubleML/doubleml.github.io |
| 82 | + branch: main |
| 83 | + folder: docs/dev |
| 84 | + target-folder: r/dev |
| 85 | + git-config-name: DoubleML Deploy Bot |
| 86 | + git-config-email: DoubleML@users.noreply.github.com |
| 87 | + clean: true |
| 88 | + ssh-key: ${{ secrets.DEPLOY_KEY }} |
| 89 | + |
| 90 | + - name: Get tag |
| 91 | + run: echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV |
| 92 | + |
| 93 | + - name: Deploy to version |
| 94 | + if: ${{ github.event_name == 'release' }} |
| 95 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 96 | + with: |
| 97 | + repository-name: DoubleML/doubleml.github.io |
| 98 | + branch: main |
| 99 | + folder: docs/dev |
| 100 | + target-folder: r/${{env.RELEASE_VERSION}} |
| 101 | + git-config-name: DoubleML Deploy Bot |
| 102 | + git-config-email: DoubleML@users.noreply.github.com |
| 103 | + clean: true |
| 104 | + ssh-key: ${{ secrets.DEPLOY_KEY }} |
0 commit comments