Skip to content

ci

ci #294

Workflow file for this run

name: ci
on:
push:
branches: [ master ]
tags: [ '**' ]
pull_request:
branches: [ master ]
jobs:
build:
if: github.event_name == 'push' || github.event_name == 'release'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Get info
id: determine
shell: python
run: |
# Create a list of tags for the container image, including
# :latest, the date in YYYYMMDD, the git tag (optional), and the git short sha,
# for the registries docker.io and ghcr.io
import os
import datetime
import itertools
import subprocess as sp
git_refs = []
if os.getenv('GITHUB_REF', '').startswith('refs/tags/'):
git_refs.append(os.getenv('GITHUB_REF')[10:])
registries = ['docker.io', 'ghcr.io']
repo = os.environ['GITHUB_REPOSITORY'].lower()
short_sha = sp.check_output(['git', 'rev-parse', '--short', 'HEAD'], text=True).strip()
today = datetime.date.today().strftime(r'%Y%m%d')
tags = ['latest', short_sha, today] + git_refs
names = ','.join(''.join(c) for c in itertools.product(
(r + '/' for r in registries),
[repo],
(':' + t for t in tags)
))
print(f'::set-output name=tags::{names}')
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
id: dockerhub_login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
tags: ${{ steps.determine.outputs.tags }}
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
REACT_APP_CHRIS_UI_BUILD_COMMIT=${{ github.sha }}
- name: Update DockerHub description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
short-description: ChRIS user interface
readme-filepath: ./README.md
repository: fnndsc/chris_ui