Skip to content

Commit 9613874

Browse files
committed
Patch:ci:Allow the maptool image to be built for any branch
container.yml builds the maptool container image only for a push to trunk, and it always uses the tag "trunk". A branch under review therefore has no image, and tools that consume the image cannot test that branch. gh-actions-mapserver has this problem: it converts the maps with ghcr.io/navit-gps/navit/maptool:trunk. This change adds the workflow_dispatch trigger and takes the tag from the branch name. A push to trunk still produces the tag "trunk", so nothing changes for the existing image. The branch name reaches the shell through the environment, and not through the command line, because a branch name is untrusted input. A slash in a branch name becomes a hyphen, because a tag cannot contain a slash.
1 parent 9f7ed95 commit 9613874

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/container.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- trunk
7+
# Lets you build the image for any other branch, so that a branch under
8+
# review can be tested with the tools that use this image. The tag is the
9+
# name of the branch.
10+
workflow_dispatch:
711

812
jobs:
913
build:
@@ -13,6 +17,15 @@ jobs:
1317
- name: Checkout code
1418
uses: actions/checkout@v7
1519

20+
- name: Get the image tag from the branch name
21+
id: image
22+
# A branch name can contain a slash, which a tag cannot.
23+
# github.ref_name goes through the environment, because a branch
24+
# name must not become part of the command.
25+
env:
26+
REF_NAME: ${{ github.ref_name }}
27+
run: echo "tag=${REF_NAME//\//-}" >> "$GITHUB_OUTPUT"
28+
1629
- name: Set up Docker Buildx
1730
uses: docker/setup-buildx-action@v4
1831

@@ -29,4 +42,4 @@ jobs:
2942
context: .
3043
file: contrib/container/maptool/Dockerfile
3144
push: true
32-
tags: ghcr.io/${{ github.repository }}/maptool:trunk
45+
tags: ghcr.io/${{ github.repository }}/maptool:${{ steps.image.outputs.tag }}

0 commit comments

Comments
 (0)