Skip to content

Build

Build #937

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
schedule:
# every day 1pm (UTC)
- cron: '0 13 * * *'
workflow_dispatch:
description: "Allows manual trigger via GitHub"
jobs:
build:
name: Build Job
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Docker Build Cache
id: cache
uses: actions/cache@v3
with:
path: /tmp/docker-builds
key: ${{ runner.os }}-${{ hashFiles('**/docker/build.sh') }}-${{ hashFiles('**/docker/liberica-base/Dockerfile') }}-${{ hashFiles('**/docker/liberica-jre/Dockerfile') }}-${{ hashFiles('**/.github/workflows/build.yaml') }}-${{ hashFiles('**/.github/.cache_invalidator') }}
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build docker images
run: |
mkdir -p /tmp/docker-builds
mkdir .tmp
cp -r /tmp/docker-builds .tmp/docker-builds.pre
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Building and pushing Docker images"
docker/build.sh push
else
echo "Building Docker images"
docker/build.sh
fi
cp -r /tmp/docker-builds .tmp/docker-builds.post
- name: Update cache invalidator
if: ${{ hashFiles('**/.tmp/docker-builds.pre/*') != hashFiles('**/.tmp/docker-builds.post/*') && steps.cache.outputs.cache-hit == 'true'}}
run: |
dd if=/dev/urandom of=.github/.cache_invalidator bs=1K count=1
echo "[user]
name = GitHub Actions
email = [email protected]" >> "${HOME}/.gitconfig"
git fetch origin
git checkout ${{ github.head_ref || github.ref_name }}
git add .github/.cache_invalidator
git commit -m "Update cache invalidator"
git push