├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ └── release-please.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── action.yml └── build_opts_check.sh /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @xynydev -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | 6 | permissions: 7 | contents: write 8 | pull-requests: write 9 | 10 | name: release-please 11 | 12 | jobs: 13 | release-please: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4.2.0 17 | id: release 18 | with: 19 | release-type: simple 20 | 21 | # tag major and minor versions 22 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 23 | - name: tag major and minor versions 24 | if: ${{ steps.release.outputs.release_created }} 25 | run: | 26 | git config user.name github-actions[bot] 27 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com 28 | git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/googleapis/release-please-action.git" 29 | git tag -d v${{ steps.release.outputs.major }} || true 30 | git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true 31 | git push origin :v${{ steps.release.outputs.major }} || true 32 | git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true 33 | git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" 34 | git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}" 35 | git push origin v${{ steps.release.outputs.major }} 36 | git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} 37 | 38 | # upload action.yml to release 39 | # this is used to generate versioned documentation 40 | - name: upload action.yml to release 41 | if: ${{ steps.release.outputs.release_created }} 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | run: gh release upload ${{ steps.release.outputs.tag_name }} ./action.yml 45 | 46 | 47 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.8.1](https://github.com/blue-build/github-action/compare/v1.8.0...v1.8.1) (2024-12-11) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * Check for user-provided `build_opts` ([#71](https://github.com/blue-build/github-action/issues/71)) ([b22398a](https://github.com/blue-build/github-action/commit/b22398aebb0d99f2a615f3aea68bb1851b924f7e)) 9 | 10 | ## [1.8.0](https://github.com/blue-build/github-action/compare/v1.7.0...v1.8.0) (2024-12-03) 11 | 12 | 13 | ### Features 14 | 15 | * rechunk support ([#69](https://github.com/blue-build/github-action/issues/69)) ([848d8e8](https://github.com/blue-build/github-action/commit/848d8e8e07705afb749590134658b7d1497af0d6)) 16 | 17 | ## [1.7.0](https://github.com/blue-build/github-action/compare/v1.6.2...v1.7.0) (2024-11-11) 18 | 19 | 20 | ### Features 21 | 22 | * allow providing options to `bluebuild build` command ([#63](https://github.com/blue-build/github-action/issues/63)) ([acae198](https://github.com/blue-build/github-action/commit/acae19810203662c3221286bb6bbb789061efab2)) 23 | * allow skipping the checkout step ([#61](https://github.com/blue-build/github-action/issues/61)) ([b032506](https://github.com/blue-build/github-action/commit/b032506226a640040c6fef03d004757d4b3b2184)) 24 | 25 | ## [1.6.2](https://github.com/blue-build/github-action/compare/v1.6.1...v1.6.2) (2024-10-14) 26 | 27 | 28 | ### Bug Fixes 29 | 30 | * Only install podman from opensuse repo if Ubuntu is 22.04 ([#59](https://github.com/blue-build/github-action/issues/59)) ([5fc9194](https://github.com/blue-build/github-action/commit/5fc919404609cec4aae8d4b86809cef2ba84bf36)) 31 | 32 | ## [1.6.1](https://github.com/blue-build/github-action/compare/v1.6.0...v1.6.1) (2024-06-30) 33 | 34 | 35 | ### Bug Fixes 36 | 37 | * Default maximize_build_space to true ([#54](https://github.com/blue-build/github-action/issues/54)) ([bf3f2a9](https://github.com/blue-build/github-action/commit/bf3f2a94b58b134c47edf329e49d222f17480438)) 38 | 39 | ## [1.6.0](https://github.com/blue-build/github-action/compare/v1.5.0...v1.6.0) (2024-05-31) 40 | 41 | 42 | ### Features 43 | 44 | * Add support for specifying a specific version of the CLI ([#51](https://github.com/blue-build/github-action/issues/51)) ([91ad95d](https://github.com/blue-build/github-action/commit/91ad95da3fc3d7c3b943d4f8a99d8d0e82b5c487)) 45 | * support changing working directory ([#43](https://github.com/blue-build/github-action/issues/43)) ([41cfe24](https://github.com/blue-build/github-action/commit/41cfe244bfef69c4db5f7bfdec021aa98d642fb8)) 46 | 47 | 48 | ### Bug Fixes 49 | 50 | * Allow no token to be passed in ([#49](https://github.com/blue-build/github-action/issues/49)) ([c4592d4](https://github.com/blue-build/github-action/commit/c4592d42e43b763c8d68c67947db14b8b6baeb56)) 51 | 52 | ## [1.5.0](https://github.com/blue-build/github-action/compare/v1.4.0...v1.5.0) (2024-05-01) 53 | 54 | 55 | ### Features 56 | 57 | * Add ability to squash builds ([#41](https://github.com/blue-build/github-action/issues/41)) ([f7c352d](https://github.com/blue-build/github-action/commit/f7c352d0ee88f5ea3e582a3f6153b451b10d418f)) 58 | 59 | ## [1.4.0](https://github.com/blue-build/github-action/compare/v1.3.1...v1.4.0) (2024-04-26) 60 | 61 | 62 | ### Features 63 | 64 | * Add support for recipes in ./recipes and add cache support ([#39](https://github.com/blue-build/github-action/issues/39)) ([b121a8f](https://github.com/blue-build/github-action/commit/b121a8f9ca987bf21989b5ba729d2bcfe0a3e3d4)) 65 | 66 | ## [1.3.1](https://github.com/blue-build/github-action/compare/v1.3.0...v1.3.1) (2024-04-13) 67 | 68 | 69 | ### Bug Fixes 70 | 71 | * switch to new build space maximer action ([#35](https://github.com/blue-build/github-action/issues/35)) ([4ca0217](https://github.com/blue-build/github-action/commit/4ca0217c3f353a5c0345b83d209ff72e98525cfe)) 72 | 73 | ## [1.3.0](https://github.com/blue-build/github-action/compare/v1.2.0...v1.3.0) (2024-03-29) 74 | 75 | 76 | ### Features 77 | 78 | * upgrade bluebuild cli version ([#31](https://github.com/blue-build/github-action/issues/31)) ([8be425d](https://github.com/blue-build/github-action/commit/8be425d5fd6bd1b3009b0cdbff35e4be2970de00)) 79 | 80 | ## [1.2.0](https://github.com/blue-build/github-action/compare/v1.1.1...v1.2.0) (2024-03-12) 81 | 82 | 83 | ### Features 84 | 85 | * add input to use unstable cli ([#17](https://github.com/blue-build/github-action/issues/17)) ([#26](https://github.com/blue-build/github-action/issues/26)) ([229504e](https://github.com/blue-build/github-action/commit/229504e5e1755dbd7b800a074f9800d88a46fc85)) 86 | 87 | 88 | ### Bug Fixes 89 | 90 | * Remove extra curly braces ([1e5f19a](https://github.com/blue-build/github-action/commit/1e5f19ac32e372e81e967a62f88cbd8b9bedfd1f)) 91 | * use docker to build images ([#16](https://github.com/blue-build/github-action/issues/16)) ([#29](https://github.com/blue-build/github-action/issues/29)) ([3475a0c](https://github.com/blue-build/github-action/commit/3475a0c8e793c7460b42f62c2d970edf2e3918b6)) 92 | 93 | ## [1.1.1](https://github.com/blue-build/github-action/compare/v1.1.0...v1.1.1) (2024-02-26) 94 | 95 | 96 | ### Bug Fixes 97 | 98 | * **release-please:** add id to release step to make subsequent steps work ([64942c5](https://github.com/blue-build/github-action/commit/64942c55e35e567dbd20df06f4583fe4004d9749)) 99 | 100 | ## [1.1.0](https://github.com/blue-build/github-action/compare/v1.0.2...v1.1.0) (2024-02-25) 101 | 102 | 103 | ### Features 104 | 105 | * add registry input ([#14](https://github.com/blue-build/github-action/issues/14)) ([9f6f8ed](https://github.com/blue-build/github-action/commit/9f6f8ed00bfc382d4027cb5626ed4e19908c9a5b)) 106 | * add release-please & multi-tag releases ([#12](https://github.com/blue-build/github-action/issues/12)) ([117a659](https://github.com/blue-build/github-action/commit/117a659ca3ce9c9b34d623acec1d392736d8158a)) 107 | * containerd mount for faster builds and cli version update ([#22](https://github.com/blue-build/github-action/issues/22)) ([aef8fcf](https://github.com/blue-build/github-action/commit/aef8fcff7a91c37eaa543269f8f0cab4dceab374)) 108 | * make maximizing build space optional ([#18](https://github.com/blue-build/github-action/issues/18)) ([3052739](https://github.com/blue-build/github-action/commit/305273971b397c8e9a73524600ec63672ed95227)) 109 | 110 | 111 | ### Bug Fixes 112 | 113 | * builds failing due to input desc examples being evaluated by github ([5d69b36](https://github.com/blue-build/github-action/commit/5d69b367446f05598400038a52eab06dc81bdf56)) 114 | * builds failing due to input desc examples being evaluated by github ([c0cabfd](https://github.com/blue-build/github-action/commit/c0cabfd6f6517e49a001ffbe2bd8d11d8d1af212)) 115 | * run build with cli container ([#15](https://github.com/blue-build/github-action/issues/15)) ([2cccc96](https://github.com/blue-build/github-action/commit/2cccc962ad4daae4741671898a494351a35a9af7)) 116 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BlueBuild GitHub Action 2 | 3 | This reusable Action can be used to build custom operating system images using BlueBuild tools. Check out the [template](https://github.com/blue-build/template) for an example of this Action in use. Check out the [reference page](https://blue-build.org/reference/github-action/) on the website for the list of inputs with documentation. -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "BlueBuild" 2 | description: "Build a custom OS image" 3 | inputs: 4 | recipe: 5 | description: | 6 | The [recipe](https://blue-build.org/reference/recipe/) file to build the image from, relative to the `config/` or `recipes/` directory. 7 | required: true 8 | default: "recipe.yml" 9 | cosign_private_key: 10 | description: | 11 | The Sigstore/cosign secret used to sign the image. 12 | 13 | Example: `${{ secrets.SIGNING_SECRET }}` 14 | required: true 15 | registry_token: 16 | description: | 17 | The token used to sign into the container registry. 18 | 19 | Example: `${{ github.token }}` 20 | required: false 21 | default: "" 22 | registry_username: 23 | description: | 24 | The username used to sign into the container registry. 25 | required: false 26 | default: ${{ github.repository_owner }} 27 | pr_event_number: 28 | description: | 29 | The event number used to tag images pushed from pull requests. 30 | 31 | Example: `${{ github.event.number }}` 32 | required: true 33 | maximize_build_space: 34 | description: | 35 | Whether to run the unwanted software remover to maximize build space in the GitHub builder. 36 | Disable this with 'false' if your image doesn't take up a lot of space and you'd rather have shorter build times. 37 | required: false 38 | default: "true" 39 | use_unstable_cli: 40 | description: | 41 | If true, this action pulls the `main` branch of blue-build/cli instead of the stable version the current action version is configured to use by default. 42 | This feature is useful for testing new features, but should not be used in production. 43 | Input must match the string 'true' for the unstable version to be used. 44 | required: false 45 | default: "false" 46 | cli_version: 47 | description: | 48 | Set this with a tag, sha, or branch name for the blue-build/cli repo to use that particular version of the CLI tool. This will override the `use_unstable_cli` input for the action. 49 | required: false 50 | registry: 51 | description: | 52 | The container registry to push the built image to. 53 | required: false 54 | default: "ghcr.io" 55 | registry_namespace: 56 | description: | 57 | The namespace on the registry to push to. 58 | 59 | Example: `ublue-os` 60 | required: false 61 | default: ${{ github.repository_owner }} 62 | rechunk: 63 | description: | 64 | Rechunk the ostree-based result images with [github.com/hhd-dev/rechunk](https://github.com/hhd-dev/rechunk) for more efficient diffs and updates. (lower image size, better download speed, better update resuming) 65 | 66 | Will make your builds considerably slower. This is an experimental option, as it can cause issues with file permissions in some scenarios, so enable on your own risk. 67 | 68 | Internally builds squashed images with podman to further reduce the image size. 69 | required: false 70 | default: "false" 71 | use_cache: 72 | description: | 73 | Make use of layer cache by pushing the layers to the registry. Input must match the string 'true' for the step to be enabled. 74 | required: false 75 | default: "true" 76 | squash: 77 | description: | 78 | Uses buildah to squash the build's layers into a single layer. Use of this option 79 | disables cache. Conflicts with adding `--build-driver` or `--squash` to the build opts. 80 | required: false 81 | default: "false" 82 | build_opts: 83 | description: | 84 | Provide options to the call to the BlueBuild CLI build command. If you use this with 85 | the squash input set to true and provide either of the `--build-driver` or `--squash` flags 86 | an error will occur and the action will not run. 87 | required: false 88 | default: " " 89 | working_directory: 90 | description: | 91 | Changes working directory for whole build. 92 | For example, setting this to `./abc/` would cause for the recipe to be read from `./abc/recipes/recipe.yml`. 93 | required: false 94 | default: ./ 95 | skip_checkout: 96 | description: | 97 | Set to true to skip doing the actions/checkout step. 98 | This allows you to checkout manually before calling bluebuild/github-action 99 | and to modify files (such as supplying build information to other scripts) before building. 100 | required: false 101 | default: "false" 102 | 103 | runs: 104 | using: "composite" 105 | steps: 106 | - name: Validate inputs 107 | shell: bash 108 | run: "${{ github.action_path }}/build_opts_check.sh" 109 | env: 110 | SQUASH_INPUT_VALUE: "${{ inputs.squash }}" 111 | BUILD_OPTS: "${{ inputs.build_opts }}" 112 | # building custom images might take a lot of space, 113 | # so it's best to remove unneeded softawre 114 | - name: Maximize build space 115 | uses: jlumbroso/free-disk-space@v1.3.1 116 | if: ${{ inputs.maximize_build_space == 'true' }} 117 | 118 | - name: Set up Docker Buildx 119 | uses: docker/setup-buildx-action@v3 120 | if: ${{ inputs.squash != 'true' && inputs.rechunk != 'true' }} 121 | with: 122 | install: true 123 | driver: docker-container 124 | cache-binary: ${{ inputs.use_cache }} 125 | 126 | - name: Get Ubuntu version 127 | id: ubuntu_version 128 | shell: bash 129 | run: | 130 | VERSION=$(awk -F= '/^VERSION_ID=/ {gsub(/"/, "", $2); print $2}' /etc/os-release) 131 | echo "Ubuntu version is $VERSION" 132 | echo "version=$VERSION" >> $GITHUB_OUTPUT 133 | 134 | # that is compatible with BlueBuild 135 | - name: Setup Podman 136 | if: ${{ (inputs.squash == 'true' || inputs.rechunk == 'true') && steps.ubuntu_version.outputs.version == '22.04' }} 137 | shell: bash 138 | run: | 139 | # from https://askubuntu.com/questions/1414446/whats-the-recommended-way-of-installing-podman-4-in-ubuntu-22-04 140 | ubuntu_version='22.04' 141 | key_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key" 142 | sources_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}" 143 | echo "deb $sources_url/ /" | sudo tee /etc/apt/sources.list.d/devel-kubic-libcontainers-unstable.list 144 | curl -fsSL $key_url | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null 145 | sudo apt-get update 146 | sudo apt-get install -y podman 147 | 148 | - uses: sigstore/cosign-installer@v3.8.2 149 | with: 150 | install-dir: /usr/bin 151 | use-sudo: true 152 | 153 | # clones user's repo 154 | - uses: actions/checkout@v4 155 | if: ${{ inputs.skip_checkout == 'false' }} 156 | 157 | - name: Determine Vars 158 | id: build_vars 159 | shell: bash 160 | env: 161 | RECIPE: ${{ inputs.recipe }} 162 | run: | 163 | if [[ "${{ inputs.use_unstable_cli }}" == "true" && -z "${{ inputs.cli_version }}" ]]; then 164 | CLI_VERSION_TAG="main" 165 | elif [ -n "${{ inputs.cli_version }}" ]; then 166 | CLI_VERSION_TAG="${{ inputs.cli_version }}" 167 | else 168 | CLI_VERSION_TAG="v0.9" 169 | fi 170 | echo "cli_version=${CLI_VERSION_TAG}" >> ${GITHUB_OUTPUT} 171 | 172 | RECIPE_PATH="" 173 | if [ -f "./config/${RECIPE}" ]; then 174 | RECIPE_PATH="./config/${RECIPE}" 175 | else 176 | RECIPE_PATH="./recipes/${RECIPE}" 177 | fi 178 | echo "recipe_path=${RECIPE_PATH}" >> ${GITHUB_OUTPUT} 179 | 180 | - name: Install BlueBuild 181 | shell: bash 182 | env: 183 | CLI_VERSION_TAG: ${{ steps.build_vars.outputs.cli_version }} 184 | run: | 185 | sudo docker create \ 186 | --name blue-build-installer \ 187 | ghcr.io/blue-build/cli:${{ env.CLI_VERSION_TAG }}-installer 188 | sudo docker cp blue-build-installer:/out/bluebuild /usr/bin/bluebuild 189 | sudo docker rm blue-build-installer 190 | bluebuild --version 191 | 192 | # blue-build/cli does the heavy lifting 193 | - name: Build Image 194 | shell: bash 195 | working-directory: ${{ inputs.working_directory }} 196 | env: 197 | COSIGN_PRIVATE_KEY: ${{ inputs.cosign_private_key }} 198 | GH_TOKEN: ${{ inputs.registry_token }} 199 | BB_PASSWORD: ${{ inputs.registry_token }} 200 | BB_USERNAME: ${{ inputs.registry_username }} 201 | BB_REGISTRY: ${{ inputs.registry }} 202 | BB_REGISTRY_NAMESPACE: ${{ inputs.registry_namespace }} 203 | GH_PR_EVENT_NUMBER: ${{ inputs.pr_event_number }} 204 | BB_CACHE_LAYERS: ${{ inputs.use_cache }} 205 | RECIPE_PATH: ${{ steps.build_vars.outputs.recipe_path }} 206 | RUST_LOG_STYLE: always 207 | CLICOLOR_FORCE: "1" 208 | BUILD_OPTS: ${{ inputs.build_opts }} 209 | run: | 210 | if [ "${{ inputs.squash }}" = "true" ]; then 211 | BUILD_OPTS="--build-driver podman --squash $BUILD_OPTS" 212 | fi 213 | 214 | RUN_SUDO="" 215 | if [ "${{ inputs.rechunk }}" = "true" ]; then 216 | RUN_SUDO=1 217 | BUILD_OPTS="--rechunk $BUILD_OPTS" 218 | fi 219 | 220 | if [ -n "$RUN_SUDO" ]; then 221 | sudo -E bluebuild build -v --push ${BUILD_OPTS} ${RECIPE_PATH} 222 | else 223 | bluebuild build -v --push ${BUILD_OPTS} ${RECIPE_PATH} 224 | fi 225 | -------------------------------------------------------------------------------- /build_opts_check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | # Expected env vars: 5 | # SQUASH_INPUT_VALUE 6 | # BUILD_OPTS 7 | 8 | # check_build_opts "option1" "option2" "error_message" 9 | # If you have only 1 option to provide, provide '---' string as 2nd placeholder option 10 | # check_build_opts "option1" --- "error_message" 11 | check_build_opts() { 12 | local option1="${1}" 13 | local option2="${2}" 14 | local error_message="${3}" 15 | 16 | if [[ "${2}" == "---" ]]; then 17 | if [[ -n "$(awk '/(^|\s)('${option1}')($|\s)/' <<< "${BUILD_OPTS}")" ]]; then 18 | echo "${error_message}" 19 | exit 1 20 | fi 21 | elif [[ -n "${2}" ]]; then 22 | if [[ -n "$(awk '/(^|\s)('${option1}'|'${option2}')($|\s)/' <<< "${BUILD_OPTS}")" ]]; then 23 | echo "${error_message}" 24 | exit 1 25 | fi 26 | fi 27 | } 28 | 29 | if [[ "${SQUASH_INPUT_VALUE}" != "true" ]]; then 30 | check_build_opts "-B" "--build-driver" "Cannot provide '--build-driver' in build_opts while 'squash' is set to true." 31 | check_build_opts "-s" "--squash" "Cannot provide '--squash' in build_opts while 'squash' is set to true." 32 | fi 33 | 34 | check_build_opts "-p" "--push" "Please do not add '--push' to build_opts, as the action already provides that argument." 35 | 36 | exit 0 37 | --------------------------------------------------------------------------------