Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore safe Docker publishing #239

Merged
merged 2 commits into from
Jul 4, 2024
Merged

Conversation

colincasey
Copy link
Contributor

This fix restores the safety of triggering the release automation on an existing release which was lost in the updates for publishing multi-arch Docker images in #194.

The buildpack matrix output can contain two variants of images to publish:

  • A CNB with a single target. E.g.;

    {
      "buildpack_id": "heroku/nodejs-function",
      "buildpack_version": "3.2.6",
      "buildpack_type": "composite",
      "buildpack_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/meta-buildpacks/nodejs-function",
      "targets": [
        {
          "os": "linux",
          "arch": "amd64",
          "rust_triple": "x86_64-unknown-linux-musl",
          "oci_target": "linux/amd64",
          "cnb_file": "heroku_nodejs-function.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-function:3.2.6",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-function:_9781380433",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/x86_64-unknown-linux-musl/release/heroku_nodejs-function"
        }
      ],
      "image_repository": "docker.io/heroku/buildpack-nodejs-function",
      "stable_tag": "docker.io/heroku/buildpack-nodejs-function:3.2.6",
      "temporary_tag": "docker.io/heroku/buildpack-nodejs-function:_9781380433"
    }
  • Or a CNB with multiple targets. E.g.;

    {
      "buildpack_id": "heroku/nodejs-npm-install",
      "buildpack_version": "3.2.6",
      "buildpack_type": "libcnb",
      "buildpack_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/buildpacks/nodejs-npm-install",
      "targets": [
        {
          "os": "linux",
          "arch": "amd64",
          "rust_triple": "x86_64-unknown-linux-musl",
          "oci_target": "linux/amd64",
          "cnb_file": "heroku_nodejs-npm-install_linux-amd64.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6_linux-amd64",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433_linux-amd64",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/x86_64-unknown-linux-musl/release/heroku_nodejs-npm-install"
        },
        {
          "os": "linux",
          "arch": "arm64",
          "rust_triple": "aarch64-unknown-linux-musl",
          "oci_target": "linux/arm64",
          "cnb_file": "heroku_nodejs-npm-install_linux-arm64.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6_linux-arm64",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433_linux-arm64",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/aarch64-unknown-linux-musl/release/heroku_nodejs-npm-install"
        }
      ],
      "image_repository": "docker.io/heroku/buildpack-nodejs-npm-install",
      "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6",
      "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433"
    }

When the automation runs successfully, either a single image or multiple images + a manifest list will have been published. Both the single image and manifest list are tagged with the value matrix.stable_tag. Therefore, if this tag exists, we shouldn't need to publish anything to Docker and we can skip that work.

Fixes #238

…an existing release which was lost in the updates for publishing multi-arch Docker images in #194.

The buildpack matrix output can contain two variants of images to publish:

- A CNB with a single target. E.g.;

    ```json
    {
      "buildpack_id": "heroku/nodejs-function",
      "buildpack_version": "3.2.6",
      "buildpack_type": "composite",
      "buildpack_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/meta-buildpacks/nodejs-function",
      "targets": [
        {
          "os": "linux",
          "arch": "amd64",
          "rust_triple": "x86_64-unknown-linux-musl",
          "oci_target": "linux/amd64",
          "cnb_file": "heroku_nodejs-function.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-function:3.2.6",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-function:_9781380433",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/x86_64-unknown-linux-musl/release/heroku_nodejs-function"
        }
      ],
      "image_repository": "docker.io/heroku/buildpack-nodejs-function",
      "stable_tag": "docker.io/heroku/buildpack-nodejs-function:3.2.6",
      "temporary_tag": "docker.io/heroku/buildpack-nodejs-function:_9781380433"
    }
    ```

- Or a CNB with multiple targets. E.g.;

    ```json
    {
      "buildpack_id": "heroku/nodejs-npm-install",
      "buildpack_version": "3.2.6",
      "buildpack_type": "libcnb",
      "buildpack_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/buildpacks/nodejs-npm-install",
      "targets": [
        {
          "os": "linux",
          "arch": "amd64",
          "rust_triple": "x86_64-unknown-linux-musl",
          "oci_target": "linux/amd64",
          "cnb_file": "heroku_nodejs-npm-install_linux-amd64.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6_linux-amd64",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433_linux-amd64",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/x86_64-unknown-linux-musl/release/heroku_nodejs-npm-install"
        },
        {
          "os": "linux",
          "arch": "arm64",
          "rust_triple": "aarch64-unknown-linux-musl",
          "oci_target": "linux/arm64",
          "cnb_file": "heroku_nodejs-npm-install_linux-arm64.cnb",
          "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6_linux-arm64",
          "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433_linux-arm64",
          "output_dir": "/home/runner/work/buildpacks-nodejs/buildpacks-nodejs/./packaged/aarch64-unknown-linux-musl/release/heroku_nodejs-npm-install"
        }
      ],
      "image_repository": "docker.io/heroku/buildpack-nodejs-npm-install",
      "stable_tag": "docker.io/heroku/buildpack-nodejs-npm-install:3.2.6",
      "temporary_tag": "docker.io/heroku/buildpack-nodejs-npm-install:_9781380433"
    }
    ```

When the automation runs successfully, either a single image or multiple images + a manifest list will have been published. Both the single image and manifest list are tagged with the value `matrix.stable_tag`. Therefore, if this tag exists, we shouldn't need to publish anything to Docker and we can skip that work.

Fixes #238
@colincasey colincasey self-assigned this Jul 4, 2024
@colincasey colincasey requested a review from a team as a code owner July 4, 2024 17:53
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this! :-)

.github/workflows/_buildpacks-release.yml Outdated Show resolved Hide resolved
@colincasey
Copy link
Contributor Author

Verified it's working as expected in this test run:
https://github.com/heroku/buildpacks-nodejs/actions/runs/9799098390/job/27058768319

@colincasey colincasey merged commit b328a22 into main Jul 4, 2024
2 checks passed
@colincasey colincasey deleted the fix_docker_published_check branch July 4, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The publishing buildpacks to docker step doesn't check if the tag already exists
2 participants