variables: - group: GH - name: R_LIBS_USER value: '$(Agent.BuildDirectory)/R/library' pool: vmImage: 'ubuntu-latest' container: $[variables['rockerImage']] steps: - bash: | export CLOUDYR_REPO=$(echo $(Build.Repository.Name) | sed "s/Azure/cloudyr/") git push --prune https://$(ghPat)@github.com/$CLOUDYR_REPO +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/* displayName: 'Copy to Cloudyr' condition: eq(variables['Build.SourceBranch'], 'refs/heads/master') - bash: | echo "options(repos = '$(cranRepo)')" > ~/.Rprofile echo ".libPaths(c('$R_LIBS_USER', .libPaths()))" >> ~/.Rprofile mkdir -p $R_LIBS_USER displayName: 'Setup R library directory' - task: CacheBeta@0 inputs: key: ./DESCRIPTION | "$(rockerImage)" | "$(cranRepo)" path: $(R_LIBS_USER) displayName: 'Caching packages' - bash: | Rscript -e "pkgs <- c('remotes', 'rcmdcheck', 'drat'); if(length(find.package(pkgs, quiet=TRUE)) != length(pkgs)) install.packages(pkgs)" Rscript -e "remotes::install_deps(dependencies=TRUE)" displayName: 'Installing package dependencies' - bash: | Rscript -e "f <- pkgbuild::build(dest_path='$(Build.ArtifactStagingDirectory)'); rcmdcheck::rcmdcheck(f, args='--no-manual', error_on='warning', check_dir='check')" displayName: 'Checking package' - bash: | export PKGBUILD_GZ=$(ls $(Build.ArtifactStagingDirectory)/*.gz) mkdir drat cd drat git init git config user.email "dummy@example.com" git config user.name "Azure Pipelines" git remote add upstream "https://$(ghPat)@github.com/cloudyr/cloudyr.github.io.git" git fetch upstream git checkout master Rscript -e "drat::insertPackage('$PKGBUILD_GZ', repodir='./drat')" git add --all git commit -m "add $PKGBUILD_GZ (build $(Build.BuildId))" git push displayName: 'Update Cloudyr drat' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))