|
9 | 9 | IMAGE_NAME: |
10 | 10 | description: "Docker image name" |
11 | 11 | value: ${{ jobs.build-image-and-test-docs.outputs.IMAGE_NAME }} |
12 | | - image_tag: |
13 | | - description: "First image tag" |
14 | | - value: ${{ jobs.build-image-and-test-docs.outputs.image_tag }} |
| 12 | + version_tag: |
| 13 | + description: "Version tag from Dockerfile" |
| 14 | + value: ${{ jobs.check-version.outputs.VERSION_TAG }} |
15 | 15 |
|
16 | | -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. |
| 16 | +# Defines custom environment variables for the workflow. |
17 | 17 | env: |
18 | 18 | REGISTRY: ghcr.io |
19 | | - IMAGE_NAME: ${{ github.repository }}/ctsm-docs |
| 19 | + IMAGE_BASENAME: ctsm-docs |
| 20 | + REPO: ${{ github.repository }} |
20 | 21 |
|
21 | 22 | # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. |
22 | 23 | jobs: |
|
25 | 26 | # Variables that might be needed by the calling workflow |
26 | 27 | outputs: |
27 | 28 | REGISTRY: ${{ env.REGISTRY }} |
28 | | - IMAGE_NAME: ${{ env.IMAGE_NAME }} |
29 | | - image_tag: ${{ steps.set-image-tag.outputs.IMAGE_TAG }} |
| 29 | + IMAGE_NAME: ${{ steps.set-image-name.outputs.IMAGE_NAME }} |
30 | 30 | # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. |
31 | 31 | permissions: |
32 | 32 | contents: read |
|
39 | 39 | - name: Checkout repository |
40 | 40 | uses: actions/checkout@v4 |
41 | 41 |
|
| 42 | + # Ensure that the repository part of IMAGE_NAME is lowercase. This is needed because Docker requires image names to be entirely lowercase. Note that the *image name* part, set as IMAGE_BASENAME in the env block above, is *not* converted. This will cause the check-version job to fail if the IMAGE_BASENAME contains capitals. We don't want to silently fix that here; rather, we require the user to specify a lowercase IMAGE_BASENAME. |
| 43 | + - name: Get image name with lowercase repo |
| 44 | + id: set-image-name |
| 45 | + run: | |
| 46 | + lowercase_repo=$(echo $REPO | tr '[:upper:]' '[:lower:]') |
| 47 | + echo "IMAGE_NAME=${lowercase_repo}/${IMAGE_BASENAME}" >> $GITHUB_ENV |
| 48 | + echo "IMAGE_NAME=${lowercase_repo}/${IMAGE_BASENAME}" >> $GITHUB_OUTPUT |
| 49 | +
|
42 | 50 | # Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. |
43 | 51 | - name: Log in to the Container registry |
44 | 52 | uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
|
52 | 60 | id: meta |
53 | 61 | uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
54 | 62 | with: |
55 | | - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 63 | + images: ${{ env.REGISTRY }}/${{ steps.set-image-name.outputs.IMAGE_NAME }} |
56 | 64 |
|
57 | 65 | # This step uses the `docker/build-push-action` action to build the image, based on the ctsm-docs `Dockerfile`. |
58 | 66 | # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository. |
|
75 | 83 | - name: Set image tag for docs build |
76 | 84 | id: set-image-tag |
77 | 85 | run: | |
78 | | - echo "IMAGE_TAG=$(echo '${{ steps.meta.outputs.tags }}' | cut -d',' -f1)" >> $GITHUB_ENV |
79 | | - echo "IMAGE_TAG=$(echo '${{ steps.meta.outputs.tags }}' | cut -d',' -f1)" >> $GITHUB_OUTPUT |
80 | | - - name: Build docs using container |
| 86 | + echo "IMAGE_TAG=$(echo '${{ steps.meta.outputs.tags }}' | head -n 1 | cut -d',' -f1)" >> $GITHUB_ENV |
| 87 | + - name: Build docs using Docker (Podman has trouble on GitHub runners) |
81 | 88 | id: build-docs |
82 | 89 | run: | |
83 | 90 | cd doc && ./build_docs -b ${PWD}/_build -c -d -i $IMAGE_TAG |
| 91 | +
|
| 92 | +
|
| 93 | + check-version: |
| 94 | + needs: build-image-and-test-docs |
| 95 | + uses: ./.github/workflows/docker-image-get-version.yml |
| 96 | + with: |
| 97 | + registry: ${{ needs.build-image-and-test-docs.outputs.REGISTRY }} |
| 98 | + image_name: ${{ needs.build-image-and-test-docs.outputs.IMAGE_NAME }} |
0 commit comments