|
10 | 10 | branches: |
11 | 11 | - main |
12 | 12 | paths-ignore: |
13 | | - - '**/README.md' |
| 13 | + - '**.md' |
14 | 14 | - '/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 |
21 | 15 |
|
| 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 |
22 | 21 | jobs: |
23 | | - build_push: |
24 | | - name: Build and push image |
| 22 | + bluebuild: |
| 23 | + name: Build Custom Image |
25 | 24 | runs-on: ubuntu-latest |
26 | 25 |
|
27 | 26 | permissions: |
28 | 27 | contents: read |
29 | 28 | packages: write |
30 | 29 | id-token: write |
31 | 30 |
|
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 |
79 | 37 |
|
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 |
129 | 42 | 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 }} |
146 | 47 |
|
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