install docker #323
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Website and Docker | ||
on: [push, workflow_dispatch] | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
job1: | ||
runs-on: ubuntu-22.04 | ||
container: rocker/verse:latest | ||
steps: | ||
- name: Checkout repository and submodules | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
# System dependencies | ||
- name: Install apt dependencies | ||
run: | | ||
apt-get update | ||
apt-get -y upgrade | ||
apt-get -y install rsync libv8-dev #for deploy and dagitty | ||
curl -fsSL https://get.docker.com -o install-docker.sh | ||
sh install-docker.sh | ||
# Git submodule init fails with unsafe repository | ||
- name: Add exception for /home/rstudio | ||
run: git config --global --add safe.directory /home/rstudio | ||
# Workaround: https://github.com/docker/build-push-action/issues/461 | ||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Query dependencies and update old packages | ||
run: | | ||
repos = install.packages('remotes') | ||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | ||
shell: Rscript {0} | ||
- name: Cache R packages | ||
if: runner.os == 'Linux' | ||
uses: actions/cache@v1 | ||
with: | ||
path: /usr/local/lib/R/site-library | ||
key: ${{ runner.os }}-r-1-${{ hashFiles('.github/depends.Rds') }} | ||
restore-keys: ${{ runner.os }}-r-1- | ||
# This lets us augment with additional dependencies | ||
- name: Install system dependencies | ||
if: runner.os == 'Linux' | ||
env: | ||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc | ||
run: | | ||
Rscript -e "remotes::install_github('r-hub/sysreqs')" | ||
Rscript -e "install.packages('pkgdown')" | ||
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") | ||
sudo -s eval "$sysreqs" | ||
- name: Install dependencies | ||
run: | | ||
remotes::install_deps(dependencies = TRUE) | ||
remotes::install_cran("rcmdcheck") | ||
shell: Rscript {0} | ||
- name: Check | ||
env: | ||
_R_CHECK_CRAN_INCOMING_REMOTE_: false | ||
run: | | ||
rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "error", check_dir = "check") | ||
shell: Rscript {0} | ||
- name: Build pkgdown | ||
run: | | ||
PATH=$PATH:$HOME/bin/ Rscript -e 'rmarkdown::render("README.Rmd", output_file = "README.md")' | ||
PATH=$PATH:$HOME/bin/ Rscript -e 'pkgdown::build_site(".")' | ||
- name: Update README.md | ||
uses: @v2.9 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
push-branch: 'main' | ||
commit-message: 'Update README.md' | ||
force-add: 'true' | ||
files: README.md session* | ||
name: Levi's GitHub Robot | ||
email: [email protected] | ||
- name: Deploy ð | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: gh-pages # The branch the action should deploy to. | ||
folder: docs # The folder the action should deploy. | ||
workspace: $GITHUB_WORKSPACE | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest | ||
# Sign the resulting Docker image digest except on PRs. | ||
# This will only write to the public Rekor transparency log when the Docker | ||
# repository is public to avoid leaking data. If you would like to publish | ||
# transparency data even for private images, pass --force to cosign below. | ||
# https://github.com/sigstore/cosign | ||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
COSIGN_EXPERIMENTAL: "true" | ||
# This step uses the identity token to provision an ephemeral certificate | ||
# against the sigstore community Fulcio instance. | ||
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} |