-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (51 loc) · 1.93 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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