Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .github/workflows/build_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,6 @@ jobs:
ref: ${{ inputs.from }}
path: build

- name: Get tag
id: get-tag
shell: bash
run: |
ref=${{ inputs.from }}
if [[ $ref =~ ^[0-9a-fA-F]{40}$ ]]; then
short_sha=$(echo $ref | cut -c1-7)
echo "tag=${short_sha}" >> $GITHUB_OUTPUT
echo "Ref $ref is a Git SHA, $short_sha is used as a tag."
else
echo "tag=${ref}" >> $GITHUB_OUTPUT
echo "Ref is not a Git SHA, $ref is used as a tag or branch name."
fi

- name: Checkout repository to get config file
uses: actions/checkout@v4
with:
Expand All @@ -121,7 +107,7 @@ jobs:
pyproject_path: .dagger
workflow: build_images
config_file: ../config/.github/build_images.yaml
ref: "v1"
ref: "fix/branch-name-in-image-tag"
vars: |
repo_name="${{ github.repository }}"
flavors="${{ inputs.flavors }}"
Expand All @@ -130,11 +116,11 @@ jobs:
releases_registry="${{ vars.DOCKER_REGISTRY_RELEASES }}"
output_results="build_images_results.yaml"
type="${{ inputs.type }}"
from="${{ steps.get-tag.outputs.tag }}"
from="${{ inputs.from }}"
workflow_run_id=${{ github.run_id}}
workflow_run_url="https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
login_required="true"
ref="v1"
ref="fix/branch-name-in-image-tag"
service_path="${{ fromJSON(vars.DOCKER_REGISTRIES_BASE_PATHS).services[inputs.type] }}"
secrets: ${{ inputs.secrets }}

Expand Down
10 changes: 8 additions & 2 deletions firestarter/workflows/build_images/build_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import yaml
import fnmatch
import subprocess
import re

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -150,11 +151,16 @@ def dereference_from_version(self):
if f'refs/tags/{self._from}' == tag_name:
return self._from

short_sha = subprocess.run(
image_tag = subprocess.run(
['git', 'rev-parse', self._from], stdout=subprocess.PIPE
).stdout.decode('utf-8')[:7]

return short_sha
# If self._from is not a SHA, we assume it's a branch.
# We append its name to the image_tag so it's easier to identify
if not re.match('^[0-9a-f]{7,40}$', self._from):
image_tag = f'{self._from}_{image_tag}'

return image_tag

def resolve_secrets(self, secrets=None):
sr = SecretResolver(secrets)
Expand Down