{"id":21633950,"url":"https://github.com/tweedegolf/build-container-image","last_synced_at":"2026-05-19T00:09:22.580Z","repository":{"id":241757820,"uuid":"807551872","full_name":"tweedegolf/build-container-image","owner":"tweedegolf","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-22T10:24:29.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T00:14:56.240Z","etag":null,"topics":["actions"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tweedegolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-29T10:14:26.000Z","updated_at":"2024-07-22T10:24:32.000Z","dependencies_parsed_at":"2024-05-30T00:56:39.879Z","dependency_job_id":"209c5a73-e532-4be0-b186-1961eb16f631","html_url":"https://github.com/tweedegolf/build-container-image","commit_stats":null,"previous_names":["tweedegolf/build-container-image"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tweedegolf%2Fbuild-container-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tweedegolf%2Fbuild-container-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tweedegolf%2Fbuild-container-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tweedegolf%2Fbuild-container-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tweedegolf","download_url":"https://codeload.github.com/tweedegolf/build-container-image/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244320298,"owners_count":20434088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions"],"created_at":"2024-11-25T03:14:43.320Z","updated_at":"2026-05-19T00:09:20.532Z","avatar_url":"https://github.com/tweedegolf.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Creating a container image\nYou can use this workflow step to create a new container image, this mostly\nrelies on the docker/build-push-action, but sets up the environment for easy\nmutli-arch builds with buildx and qemu. It also logs in to the GitHub container\nregistry allowing you to upload an image right away. To use it, add a job to\nyour GitHub workflow calling this workflow:\n\n```yaml\n# ...\n\njobs:\n\n  # ...\n\n  docker:\n    runs-on: ubuntu-latest\n    steps:\n      # ...\n\n      - name: Build container image\n        uses: tweedegolf/build-container-image@main\n        with:\n          token: ${{ secrets.GITHUB_TOKEN }}\n          push: ${{ github.ref == 'refs/heads/main' }}\n          platforms: \"linux/amd64,linux/arm64\"\n          tags: ghcr.io/tweedegolf/example:latest\n\n      # ...\n\n  # ...\n```\n\n### Workflow inputs\nThis workflow has several parameters that allow customizing the behavior:\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\u003cth\u003eOption\u003c/th\u003e\u003cth\u003eRequired\u003c/th\u003e\u003cth\u003eDefault\u003c/th\u003e\u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003etoken\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eyes\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      GitHub token for logging into the ghcr container registry\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003etags\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eyes\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      List of image tags (newline separated) for the resulting container image\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003epush\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003efalse\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      If true, the image will be pushed to the registry\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eplatforms\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"\"\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      Comma separated list of platforms to build the image for, i.e. \u003ccode\u003elinux/amd64,linux/arm64\u003c/code\u003e. If left empty, will only build for the native platform.\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003econtext\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e.\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      Context directory for the container image build\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003ebuild-args\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"\"\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      List of build arguments (newline separated) to be inserted in the container image build\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003efile\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eDockerfile\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      Name of the dockerfile to build\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eno-cache\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003etrue\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      Set to false to enable caching of docker layers\n    \u003c/td\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003epull\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eno\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003etrue\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\u003ctd colspan=\"3\"\u003e\n      Pull base images from the registry when not available locally\n    \u003c/td\u003e\u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Example usage\nBelow, you will find a working example where we either just build (and not push)\na container image on a pull request, and we fully build and push a container on\nthe main branch, these two require separate permissions. We'll also add a build\nmatrix to allow multiple images to be generated:\n\n* `.github/workflows/docker.yml`\n  ```yaml\n  name: Docker\n\n  on:\n    workflow_call:\n\n  jobs:\n    docker:\n      strategy:\n        matrix:\n          include:\n            - version: trixie\n              latest: false\n              alt: testing\n            - version: bookworm\n              latest: true\n              alt: stable\n            - version: bullseye\n              latest: false\n              alt: oldstable\n      steps:\n        - uses: actions/checkout@v4\n        - name: Build container image\n          uses: tweedegolf/build-container-image@main\n          with:\n            token: ${{ secrets.GITHUB_TOKEN }}\n            push: ${{ github.ref == 'refs/heads/main' }}\n            platforms: \"linux/amd64,linux/arm64\"\n            build-args: |\n              DEBIAN_VERSION=${{matrix.version}}\n            tags: |\n              ghcr.io/tweedegolf/debian:${{matrix.version}}\n              ghcr.io/tweedegolf/debian:${{matrix.alt}}\n              ${{ matrix.latest \u0026\u0026 'ghcr.io/tweedegolf/debian:latest' || '' }}\n  ```\n  This file will be re-used by the two workflows below. As such we only trigger\n  it on `workflow_call`. Note how we use a matrix to build multiple images. Of\n  course for this workflow to run we'll also need a Dockerfile to be built, but\n  that has been omitted in this example.\n* `.github/workflows/build-push.yml`\n  ```yaml\n  name: Build and push\n\n  permissions:\n    contents: read\n    packages: write\n\n  on:\n    push:\n      branches:\n        - main\n    schedule:\n      - cron: '30 2 * * SUN'\n\n  jobs:\n    build-and-push:\n      uses: ./.github/workflows/docker.yml\n  ```\n  This build and push workflow for the main branch also runs on a schedule every\n  week to keep the image up to date. Note how we require package write\n  permission in this workflow.\n\n* `.github/workflows/check.yml`\n  ```yaml\n  name: Checks\n\n  permissions:\n    contents: read\n\n  on:\n    pull_request:\n\n  jobs:\n    build:\n      uses: ./.github/workflows/docker.yml\n      secrets: inherit\n  ```\n  The checks workflow will just need read permissions for the repository with\n  no write permissions required. We only run it for a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftweedegolf%2Fbuild-container-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftweedegolf%2Fbuild-container-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftweedegolf%2Fbuild-container-image/lists"}