-
Notifications
You must be signed in to change notification settings - Fork 358
Fix ctsm-docs container version tagging #3128
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
Merged
samsrabin
merged 13 commits into
ESCOMP:b4b-dev
from
samsrabin:ctsm-docs-version-tagging
May 16, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
67bfa6a
ctsm-docs build/publish workflow now includes version tag.
samsrabin 51974c9
ctsm-docs container build/publish workflow: Include "latest" tag.
samsrabin 0fe1e87
ctsm-docs container: Fail publish if version tag exists.
samsrabin 6b2c83c
Don't trigger Docker image workflows if only README changes.
samsrabin 63cb052
Correct a comment in a GH workflow.
samsrabin dd730c2
Check version in Dockerfile as part of docker-image-common.yml.
samsrabin fd6d7c9
Ensure repo in IMAGE_NAME is always lowercase, per Docker rule.
samsrabin c591a7c
docker-image-get-version: Enable running on workflow dispatch.
samsrabin 5e07fd5
docker-image-get-version.yml: Minor improvements.
samsrabin fcc5664
Avoid tagging container with IMAGE_TAG (e.g., "master").
samsrabin de2609f
ctsm-docs container README: Add auto-publishing info.
samsrabin 5fc5022
ctsm-docs container README: Minor improvements.
samsrabin 5536915
Update a Workflow comment.
samsrabin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: Get and check version specified in a Dockerfile | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| registry: | ||
| required: true # Require any workflows calling this one to provide input | ||
| type: string | ||
| default: 'ghcr.io' # Provide default so this workflow works standalone too | ||
| image_name: | ||
| required: true # Require any workflows calling this one to provide input | ||
| type: string | ||
| default: 'escomp/ctsm/ctsm-docs' # Provide default so this workflow works standalone too | ||
| outputs: | ||
| VERSION_TAG: | ||
| description: "Tag to be pushed to container registry" | ||
| value: ${{ jobs.get-check-version.outputs.VERSION_TAG }} | ||
| workflow_dispatch: | ||
| inputs: | ||
| registry: | ||
| description: 'Container registry' | ||
| required: false | ||
| type: string | ||
| default: 'ghcr.io' | ||
| image_name: | ||
| description: 'Image name' | ||
| required: false | ||
| type: string | ||
| default: 'escomp/ctsm/ctsm-docs' | ||
|
|
||
| # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. | ||
| jobs: | ||
| get-check-version: | ||
| name: Get version number from Dockerfile and check it | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| VERSION_TAG: ${{ steps.get-check-version.outputs.version_tag }} | ||
| # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
|
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Get version number from Dockerfile and check it | ||
| id: get-check-version | ||
| run: | | ||
| set -e | ||
| set -o pipefail | ||
| set -u | ||
| VERSION="$(doc/ctsm-docs_container/get_version.sh)" | ||
| VERSION_TAG="${{ inputs.registry }}/${{ inputs.image_name }}:${VERSION}" | ||
|
|
||
| # Store the manifest inspect result and output | ||
| set +e | ||
| INSPECT_RESULT="$(docker manifest inspect "$VERSION_TAG" 2>&1)" | ||
| INSPECT_STATUS=$? | ||
| set -e | ||
|
|
||
| if [[ "${INSPECT_RESULT}" == *"schemaVersion"* ]]; then | ||
| echo "Tag $VERSION_TAG already exists!" >&2 | ||
| exit 123 | ||
| elif [[ "${INSPECT_RESULT}" != "manifest unknown" ]]; then | ||
| # "manifest unknown" means the tag doesn't exist, which is what we want | ||
| echo -e "Error checking manifest for $VERSION_TAG:\n${INSPECT_RESULT}" >&2 | ||
| exit $INSPECT_STATUS | ||
| fi | ||
|
|
||
| echo "Setting version_tag to $VERSION_TAG" | ||
| echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
| cd doc/ctsm-docs_container | ||
|
|
||
| # Extract version from Dockerfile | ||
| version="$(grep "org.opencontainers.image.version" Dockerfile | cut -d'"' -f2 | sort |uniq)" | ||
| n_found=$(echo $version | wc -w) | ||
|
|
||
| # Error if anything other than exactly one version tag was found | ||
| if [[ ${n_found} -gt 1 ]]; then | ||
| echo -e "Multiple version tags found:\n${version}" >&2 | ||
| exit 2 | ||
| elif [[ ${n_found} -lt 1 ]]; then | ||
| echo "Expected 1 but found 0 version tags" >&2 | ||
| exit -1 | ||
| fi | ||
|
|
||
| # Error if version doesn't start with v | ||
| if [[ "${version}" != "v"* ]]; then | ||
| echo "Version '${version}' doesn't start with v" >&2 | ||
| exit 22 | ||
| fi | ||
|
|
||
| echo ${version} | ||
|
|
||
| exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.