Skip to content

Commit 4e90496

Browse files
committed
Set up BlueBuild GitHub Actions builds
This roughly merges our existing workflow with the one in https://github.com/blue-build/template/blob/main/.github/workflows/build.yml.
1 parent 9986305 commit 4e90496

1 file changed

Lines changed: 24 additions & 129 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -10,145 +10,40 @@ on:
1010
branches:
1111
- main
1212
paths-ignore:
13-
- '**/README.md'
13+
- '**.md'
1414
- '/lint.sh'
15-
workflow_dispatch:
16-
17-
env:
18-
MY_IMAGE_NAME: "${{ github.event.repository.name }}" # the name of the image produced by this build, matches repo names
19-
MY_IMAGE_DESC: "SeaGL Aviary Linux"
20-
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" # do not edit
2115

16+
workflow_dispatch:
17+
concurrency:
18+
# only run one build at a time
19+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
20+
cancel-in-progress: true
2221
jobs:
23-
build_push:
24-
name: Build and push image
22+
bluebuild:
23+
name: Build Custom Image
2524
runs-on: ubuntu-latest
2625

2726
permissions:
2827
contents: read
2928
packages: write
3029
id-token: write
3130

32-
steps:
33-
# Checkout push-to-registry action GitHub repository
34-
- name: Checkout Push to Registry action
35-
uses: actions/checkout@v5
36-
37-
- name: Maximize build space
38-
uses: ublue-os/remove-unwanted-software@v9
39-
40-
- name: Generate tags
41-
id: generate-tags
42-
shell: bash
43-
run: |
44-
# Generate a timestamp for creating an image version history
45-
TIMESTAMP="$(date +%Y%m%d)"
46-
COMMIT_TAGS=()
47-
BUILD_TAGS=()
48-
49-
# Have tags for tracking builds during pull request
50-
SHA_SHORT="${GITHUB_SHA::7}"
51-
COMMIT_TAGS+=("pr-${{ github.event.number }}")
52-
COMMIT_TAGS+=("${SHA_SHORT}")
53-
54-
# Append matching timestamp tags to keep a version history
55-
for TAG in "${BUILD_TAGS[@]}"; do
56-
BUILD_TAGS+=("${TAG}-${TIMESTAMP}")
57-
done
58-
59-
BUILD_TAGS+=("${TIMESTAMP}")
60-
BUILD_TAGS+=("latest")
61-
62-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
63-
echo "Generated the following commit tags: "
64-
for TAG in "${COMMIT_TAGS[@]}"; do
65-
echo "${TAG}"
66-
done
67-
68-
alias_tags=("${COMMIT_TAGS[@]}")
69-
else
70-
alias_tags=("${BUILD_TAGS[@]}")
71-
fi
72-
73-
echo "Generated the following build tags: "
74-
for TAG in "${BUILD_TAGS[@]}"; do
75-
echo "${TAG}"
76-
done
77-
78-
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
31+
strategy:
32+
fail-fast: false # stop GH from cancelling all matrix builds if one fails
33+
matrix:
34+
recipe:
35+
# !! Add your recipes here
36+
- recipe.yml
7937

80-
# Build metadata
81-
- name: Image Metadata
82-
uses: docker/metadata-action@v5
83-
id: meta
84-
with:
85-
images: |
86-
${{ env.MY_IMAGE_NAME }}
87-
88-
labels: |
89-
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md
90-
org.opencontainers.image.description=${{ env.MY_IMAGE_DESC }}
91-
org.opencontainers.image.title=${{ env.MY_IMAGE_NAME }}
92-
93-
# Build image using Buildah action
94-
- name: Build Image
95-
id: build_image
96-
uses: redhat-actions/buildah-build@v2
97-
with:
98-
containerfiles: |
99-
./Containerfile
100-
# Postfix image name with -custom to make it a little more descriptive
101-
# Syntax: https://docs.github.com/en/actions/learn-github-actions/expressions#format
102-
image: ${{ env.MY_IMAGE_NAME }}
103-
tags: |
104-
${{ steps.generate-tags.outputs.alias_tags }}
105-
labels: ${{ steps.meta.outputs.labels }}
106-
oci: false
107-
108-
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
109-
# https://github.com/macbre/push-to-ghcr/issues/12
110-
- name: Lowercase Registry
111-
id: registry_case
112-
uses: ASzc/change-string-case-action@v6
113-
with:
114-
string: ${{ env.IMAGE_REGISTRY }}
115-
116-
- name: Login to GitHub Container Registry
117-
uses: docker/login-action@v3
118-
with:
119-
registry: ghcr.io
120-
username: ${{ github.actor }}
121-
password: ${{ secrets.GITHUB_TOKEN }}
122-
123-
- name: Push Image to GHCR
124-
uses: redhat-actions/push-to-registry@v2
125-
id: push
126-
env:
127-
REGISTRY_USER: ${{ github.actor }}
128-
REGISTRY_PASSWORD: ${{ github.token }}
38+
steps:
39+
# the build is fully handled by the reusable github action
40+
- name: Build Custom Image
41+
uses: blue-build/github-action@v1.8
12942
with:
130-
image: ${{ steps.build_image.outputs.image }}
131-
tags: ${{ steps.build_image.outputs.tags }}
132-
registry: ${{ steps.registry_case.outputs.lowercase }}
133-
username: ${{ env.REGISTRY_USER }}
134-
password: ${{ env.REGISTRY_PASSWORD }}
135-
extra-args: |
136-
--disable-content-trust
137-
138-
# This section is optional and only needs to be enabled in you plan on distributing
139-
# your project to others to consume. You will need to create a public and private key
140-
# using Cosign and save the private key as a repository secret in Github for this workflow
141-
# to consume. For more details, review the image signing section of the README.
142-
143-
# Sign container
144-
- uses: sigstore/cosign-installer@v3.10.0
145-
if: github.event_name != 'pull_request'
43+
recipe: ${{ matrix.recipe }}
44+
cosign_private_key: ${{ secrets.SIGNING_SECRET }}
45+
registry_token: ${{ github.token }}
46+
pr_event_number: ${{ github.event.number }}
14647

147-
- name: Sign container image
148-
if: github.event_name != 'pull_request'
149-
run: |
150-
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}@${TAGS}
151-
env:
152-
TAGS: ${{ steps.push.outputs.digest }}
153-
COSIGN_EXPERIMENTAL: false
154-
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
48+
# enabled by default, disable if your image is small and you want faster builds
49+
maximize_build_space: true

0 commit comments

Comments
 (0)