Create Tilloo Helm chart (#188) #186
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: ci | |
on: | |
workflow_dispatch: | |
# release: | |
# types: [published, edited] | |
push: | |
# branches: master | |
# pull requests are broken when pushing to ghcr | |
# pull_request: | |
# branches: master | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: | |
actions/checkout@v3 | |
# this is required to run npm install from our other private github repo | |
- uses: actions/setup-node@v3 | |
with: | |
cache: "npm" | |
cache-dependency-path: "web/client/package-lock.json" | |
node-version-file: ".nvmrc" | |
- name: Install Packages for web client | |
run: npm ci --ignore-scripts | |
working-directory: ./web/client | |
- name: Build web client | |
run: DOCKER_BUILD=true npm run build | |
working-directory: ./web/client | |
- name: Install packages for server | |
run: npm ci --only=production --ignore-scripts | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/tilloo | |
VERSION=noop | |
PLATFORMS="linux/arm64" | |
if [ "${{ github.event_name }}" = "schedule" ]; then | |
VERSION=nightly | |
elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then | |
VERSION=edge | |
fi | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MINOR=${VERSION%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6" | |
elif [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
echo ::set-output name=platforms::${PLATFORMS} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Built platforms | |
run: echo ${{ steps.prep.outputs.platforms }} | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GH_CR_PAT }} | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx2-refs/heads/${{ github.ref }} | |
restore-keys: | | |
${{ runner.os }}-buildx2-refs/heads/${{ github.ref }} | |
${{ runner.os }}-buildx2-refs/heads/${{ github.event.repository.default_branch }} | |
${{ runner.os }}-buildx2- | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
platforms: ${{ steps.prep.outputs.platforms }} | |
tags: ${{ steps.prep.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} #this is for logging. |