update geoflow #117
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: docker-build-image | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- 'main' | |
env: | |
CACHE_IMAGE: ghcr.io/r-geoflow/geoflow-shiny-cache | |
DOCKER_BUILDKIT: 1 | |
RENV_PATHS_ROOT: ~/.cache/R/renv | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/r-geoflow/geoflow-shiny | |
flavor: latest=true | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Login to image repository | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: image=moby/buildkit:master,network=host | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build Docker image | |
run: | | |
docker buildx build \ | |
--cache-from type=registry,ref=$CACHE_IMAGE:latest \ | |
--cache-to type=registry,ref=$CACHE_IMAGE:latest,mode=max \ | |
--tag ghcr.io/r-geoflow/geoflow-shiny:latest \ | |
--build-arg RENV_PATHS_ROOT=${{ env.RENV_PATHS_ROOT }} \ | |
--output type=docker,dest=/tmp/docker-image.tar \ | |
. | |
- name: Load Docker image | |
if: github.ref_type == 'tag' | |
run: | | |
docker load -i /tmp/docker-image.tar | |
- name: Conditional push Docker image | |
if: github.ref_type == 'tag' | |
run: | | |
TAG_NAME=$(basename ${GITHUB_REF}) | |
docker tag ghcr.io/r-geoflow/geoflow-shiny:latest ghcr.io/r-geoflow/geoflow-shiny:${TAG_NAME} | |
docker push ghcr.io/r-geoflow/geoflow-shiny:latest | |
docker push ghcr.io/r-geoflow/geoflow-shiny:${TAG_NAME} |