Skip to content

Commit 00be82c

Browse files
committed
ci: add scheduled container builds
Signed-off-by: Avi Miller <[email protected]>
1 parent da81b3e commit 00be82c

File tree

4 files changed

+48
-100
lines changed

4 files changed

+48
-100
lines changed

.github/workflows/docker-publish.yml

-92
This file was deleted.

.github/workflows/publish-nginx-image.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Build, publish and sign the NGINX webserver image
33

44
on:
55
workflow_dispatch:
6+
schedule:
7+
- cron: '36 6 * * *'
68
push:
79
branches: [ main ]
810
tags: [ 'v*.*.*' ]
@@ -24,7 +26,24 @@ jobs:
2426

2527
steps:
2628
- name: Checkout repository
27-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
30+
31+
- name: Check for newer base image on scheduled runs
32+
if: github.event_name == 'schedule'
33+
run: |
34+
BASE_LAYERS=$(skopeo inspect --config --no-tags docker://ghcr.io/oracle/oraclelinux:8-slim | jq -r '.rootfs.diff_ids[]')
35+
REPO_LAYERS=$(skopeo inspect --config --no-tags docker://ghcr.io/djelibeybi/ol-repo-webserver:main | jq -r '.rootfs.diff_ids[]')
36+
if [ -n "${REPO_LAYERS##*$BASE_LAYERS*}" ]; then
37+
echo "BUILD_IMAGE=YES" >> $GITHUB_ENV
38+
echo ""
39+
else
40+
echo "BUILD_IMAGE=NO" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Trigger builds for unscheduled runs
44+
if: github.event_name != 'schedule'
45+
run: |
46+
echo "BUILD_IMAGE=YES" >> $GITHUB_ENV
2847
2948
- name: Install cosign
3049
if: github.event_name != 'pull_request'
@@ -43,7 +62,7 @@ jobs:
4362
username: ${{ github.actor }}
4463
password: ${{ secrets.GITHUB_TOKEN }}
4564

46-
- name: Extract Docker metadata
65+
- name: Extract container metadata
4766
id: meta
4867
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
4968
with:
@@ -52,6 +71,7 @@ jobs:
5271
- name: Build and push Docker image
5372
id: build-and-push
5473
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
74+
if: env.BUILD_IMAGE == "YES"
5575
with:
5676
context: .
5777
file: ./Dockerfile.nginx

.github/workflows/publish-reposync-image.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Build, publish and sign the reposync image
33

44
on:
55
workflow_dispatch:
6+
schedule:
7+
- cron: '17 6 * * *'
68
push:
79
branches: [ main ]
810
tags: [ 'v*.*.*' ]
@@ -24,7 +26,24 @@ jobs:
2426

2527
steps:
2628
- name: Checkout repository
27-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
30+
31+
- name: Check for newer base image on scheduled runs
32+
if: github.event_name == 'schedule'
33+
run: |
34+
BASE_LAYERS=$(skopeo inspect --config --no-tags docker://ghcr.io/oracle/oraclelinux8-python:3.9-amd64 | jq -r '.rootfs.diff_ids[]')
35+
REPO_LAYERS=$(skopeo inspect --config --no-tags docker://ghcr.io/djelibeybi/ol-repo-sync:main | jq -r '.rootfs.diff_ids[]')
36+
if [ -n "${REPO_LAYERS##*$BASE_LAYERS*}" ]; then
37+
echo "BUILD_IMAGE=YES" >> $GITHUB_ENV
38+
echo ""
39+
else
40+
echo "BUILD_IMAGE=NO" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Trigger builds for unscheduled runs
44+
if: github.event_name != 'schedule'
45+
run: |
46+
echo "BUILD_IMAGE=YES" >> $GITHUB_ENV
2847
2948
- name: Install cosign
3049
if: github.event_name != 'pull_request'
@@ -43,23 +62,24 @@ jobs:
4362
username: ${{ github.actor }}
4463
password: ${{ secrets.GITHUB_TOKEN }}
4564

46-
- name: Extract Docker metadata
65+
- name: Extract container metadata
4766
id: meta
4867
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
4968
with:
5069
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5170

52-
- name: Build and push Docker image
71+
- name: Build and push container image
5372
id: build-and-push
5473
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
74+
if: env.BUILD_IMAGE == 'YES'
5575
with:
5676
context: .
5777
platforms: linux/amd64,linux/arm64
5878
push: ${{ github.event_name != 'pull_request' }}
5979
tags: ${{ steps.meta.outputs.tags }}
6080
labels: ${{ steps.meta.outputs.labels }}
6181

62-
- name: Sign the published Docker image
82+
- name: Sign the published container image
6383
if: ${{ github.event_name != 'pull_request' }}
6484
env:
6585
COSIGN_EXPERIMENTAL: "true"

Dockerfile.nginx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Copyright (c) 2020, 2021 Avi Miller.
1+
# Copyright (c) 2020, 2022 Avi Miller.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3-
FROM oraclelinux:8-slim
3+
FROM ghcr.io/oracle/oraclelinux:8-slim
44

55
RUN microdnf module disable php && \
66
microdnf module enable nginx:1.20 && \

0 commit comments

Comments
 (0)