diff --git a/.release-notes/add-ghcr-io-support.md b/.release-notes/add-ghcr-io-support.md new file mode 100644 index 0000000..260e9a2 --- /dev/null +++ b/.release-notes/add-ghcr-io-support.md @@ -0,0 +1,9 @@ +## Add support for GHCR.io + +We've added support for an additional registry to our two commands that were registry specific. + +`update-action-to-use-docker-image-to-run-action` now takes an environment variable `REGISTRY` to indicate which registry to use. + +`update-version-in-README` now support changing docker urls for both the default (none) and for urls targeting `ghcr.io`. + +See the README for updated usage instructions for `update-action-to-use-docker-image-to-run-action`. You don't need to make any changes for related to the `update-version-in-README` change. diff --git a/README.md b/README.md index 4aa1520..ba6489a 100644 --- a/README.md +++ b/README.md @@ -530,7 +530,20 @@ An example step config: GIT_USER_EMAIL: "ponylang.main@gmail.com" ``` -N.B. currently limited to supporting images that are uploaded to Docker Hub. +To use a registry other than DockerHub, add the registry in the REGISTRY environment variable. For example to use GitHub Container Registry: + +```yml + - name: Set action to run using prebuilt image + uses: ponylang/release-bot-action@0.6.1 + with: + entrypoint: update-action-to-use-docker-image-to-run-action + env: + GIT_USER_NAME: "Ponylang Main Bot" + GIT_USER_EMAIL: "ponylang.main@gmail.com" + REGISTRY: "ghcr.io" +``` + +Current valid entries for `REGISTRY` are '', 'docker.io', and 'ghcr.io'. ### update-action-to-use-dockerfile-to-run-action @@ -604,6 +617,7 @@ Can update the following version patterns: - corral add github.com/REPO.git --version \d+\.\d+\.\d+ - REPO@\d+\.\d+\.\d+ <== standard action url - docker://REPO:\d+\.\d+\.\d+ <== docker hub url +- docker://ghcr.io/REPO:\d+\.\d+\.\d+ <== github container registry url - **Must** be triggered by an `announce-X.Y.Z` tag push. - **Must** be run in a job after `actions/checkout` diff --git a/scripts/update-action-to-use-docker-image-to-run-action b/scripts/update-action-to-use-docker-image-to-run-action index 4d4fb25..bfd7ac3 100644 --- a/scripts/update-action-to-use-docker-image-to-run-action +++ b/scripts/update-action-to-use-docker-image-to-run-action @@ -59,11 +59,27 @@ git.config('--global', 'user.email', os.environ['GIT_USER_EMAIL']) git.config('--global', 'branch.autosetuprebase', 'always') git.config('--global', '--add', 'safe.directory', os.environ['GITHUB_WORKSPACE']) -# open README and update with new version +# open action.yml and update with new version. using the denoted registry if +# one is given +registry = '' + +if 'REGISTRY' in os.environ: + registry = os.environ['REGISTRY'] + match registry: + case '': + registry = registry + case 'docker.io': + registry = registry + '/' + case 'ghcr.io': + registry = registry + '/' + case _: + print(ERROR + registry + " isn't a supported REGISTRY. Exiting." + ENDC) + sys.exit(1) + print(INFO + "Switching to prebuilt image as runner in action.yml" + ENDC) with open('action.yml', 'r+') as action_yml: text = yaml.safe_load(action_yml) - text['runs']['image'] = f'docker://{repository}:{version}' + text['runs']['image'] = f'docker://{registry}{repository}:{version}' action_yml.seek(0) yaml.dump(text, action_yml) action_yml.truncate() diff --git a/scripts/update-version-in-README b/scripts/update-version-in-README index d77b118..7ef9942 100644 --- a/scripts/update-version-in-README +++ b/scripts/update-version-in-README @@ -57,6 +57,8 @@ git.config('--global', '--add', 'safe.directory', os.environ['GITHUB_WORKSPACE'] subs = [ (fr'docker://{repository}:\d+\.\d+\.\d+', f'docker://{repository}:{version}'), + (fr'docker://ghcr.io/{repository}:\d+\.\d+\.\d+', + f'docker://ghcr.io/{repository}:{version}'), (fr'{repository}@\d+\.\d+\.\d+', f'{repository}@{version}'), (fr'corral add github.com/{repository}.git -(-version|v) \d+\.\d+\.\d+',