From fe4d19d84b71982ebe17636fdfac72b8f7def6f0 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 13 Jun 2024 20:47:48 +0200 Subject: [PATCH] Fix autoupdate PR message (#41) * Fix PR message * Tweaks * Update create-pull-request version * Reorder --- .github/workflows/update-base-image.yml | 7 ++++--- scripts/update_base_image.py | 13 +++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update-base-image.yml b/.github/workflows/update-base-image.yml index cd7b2d6..0441995 100644 --- a/.github/workflows/update-base-image.yml +++ b/.github/workflows/update-base-image.yml @@ -22,10 +22,11 @@ jobs: python -m pip install --quiet --disable-pip-version-check -r scripts/update_base_image_reqs.txt python scripts/update_base_image.py - name: Create PR - uses: peter-evans/create-pull-request@ee93d78b55ada32aa74b5e9957aac9c2523dd22c + uses: peter-evans/create-pull-request@v6.0.5 with: branch: "update-base-image" - commit-message: "Update to micromamba base image to ${{ steps.update_dockerfile.outputs.new_docker_tag }}" - title: "Update to micromamba base image to ${{ steps.update_dockerfile.outputs.new_docker_tag }}" + commit-message: "Update to micromamba base image to ${{ env.NEW_DOCKER_TAG }}" + title: "Update to micromamba base image to ${{ env.NEW_DOCKER_TAG }}" + body: "Generated by [update-base-image.yml](https://github.com/mamba-org/micromamba-devcontainer/actions/runs/${{ github.run_id }}/workflow)" delete-branch: true reviewers: maresb diff --git a/scripts/update_base_image.py b/scripts/update_base_image.py index b35bd6d..d50b9bf 100644 --- a/scripts/update_base_image.py +++ b/scripts/update_base_image.py @@ -14,9 +14,7 @@ REGISTRY_QUERY_URL = ( "https://hub.docker.com/v2/repositories/mambaorg/micromamba/tags?page_size=200" ) -GITHUB_OUTPUT = ( - Path(os.environ["GITHUB_OUTPUT"]) if "GITHUB_OUTPUT" in os.environ else None -) +GITHUB_ENV = Path(os.environ["GITHUB_ENV"]) if "GITHUB_ENV" in os.environ else None class DockerImageTag(NamedTuple): @@ -135,11 +133,10 @@ def main(): if updated_image_tag == current_image_tag: print("No update needed for Dockerfile.") else: - new_docker_tag = update_dockerfile( - lines, - line_number, - updated_image_tag, - ) + new_docker_tag = update_dockerfile(lines, line_number, updated_image_tag) + if GITHUB_ENV: + with open(GITHUB_ENV, "a") as f: + f.write(f"NEW_DOCKER_TAG={new_docker_tag}\n") print(f"✅ Update successful: {new_docker_tag}") print("Updating workflow file...")