Skip to content

Commit 3577864

Browse files
authored
normalize branch names for docker tags and actionliknt (#2651)
Co-authored-by: jasquat <[email protected]>
1 parent 6198275 commit 3577864

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

.github/workflows/build_docker_images.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ on:
3131
push:
3232
branches:
3333
- main
34-
- api-logs
3534
tags: [v*]
3635

3736
jobs:
@@ -54,7 +53,6 @@ jobs:
5453
env:
5554
REGISTRY: ghcr.io
5655
IMAGE_NAME: ${{ matrix.image_name }}
57-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
5856
permissions:
5957
contents: read
6058
packages: write
@@ -71,6 +69,12 @@ jobs:
7169
username: ${{ github.actor }}
7270
password: ${{ secrets.GITHUB_TOKEN }}
7371

72+
- name: Normalize branch name
73+
id: normalize_branch_name
74+
run: |
75+
BRANCH_NAME=$(echo "${{ github.ref_name }}" | tr '[:upper:]' '[:lower:]' | sed -r 's/[^a-z0-9]+/-/g' | sed -r 's/^-+|-+$//g')
76+
echo "normalized_branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
77+
7478
- name: Get current date
7579
id: date
7680
run: echo "date=$(date -u +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_OUTPUT"
@@ -84,7 +88,7 @@ jobs:
8488
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8589
labels: |
8690
org.opencontainers.image.description=${{ matrix.description }}
87-
org.opencontainers.image.version=${{ env.BRANCH_NAME }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}
91+
org.opencontainers.image.version=${{ steps.normalize_branch_name.outputs.normalized_branch_name }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}
8892
tags: |
8993
type=raw,value=v1.0.0,enable=${{ github.ref_name == 'rebuild-v1.0.0' }}
9094
type=raw,value=latest,enable=${{ github.ref_name == 'rebuild-v1.0.0' }}
@@ -98,7 +102,7 @@ jobs:
98102
run: echo "$DOCKER_METADATA_OUTPUT_JSON" | jq '.labels' > version_info.json
99103
- name: Generate full image tag
100104
id: full_tag
101-
run: echo "full_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}" >> "$GITHUB_OUTPUT"
105+
run: echo "full_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.normalize_branch_name.outputs.normalized_branch_name }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}" >> "$GITHUB_OUTPUT"
102106
- name: Build Docker image
103107
uses: docker/[email protected]
104108
with:
@@ -156,4 +160,3 @@ jobs:
156160
cache-to: type=gha,mode=max
157161
- name: Adding markdown
158162
run: echo 'TAGS ${{ steps.meta.outputs.tags }}' >> "$GITHUB_STEP_SUMMARY"
159-

.github/workflows/common.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616
name: Build and publish Python 🐍 distributions 📦 to PyPI
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v6
20-
- name: Set up Python 3.12
21-
uses: actions/setup-python@v6
22-
with:
23-
python-version: "3.12"
24-
- name: Install pypa/build
25-
run: pip install --constraint=.github/workflows/constraints.txt pip uv
26-
- name: Build a binary wheel and a source tarball
27-
run: uv build spiff-arena-common
28-
- name: Publish distribution 📦 to PyPI
29-
if: github.ref == 'refs/heads/main'
30-
uses: pypa/gh-action-pypi-publish@release/v1
31-
with:
32-
username: __token__
33-
password: ${{ secrets.COMMON_PYPI_KEY }}
19+
- uses: actions/checkout@v6
20+
- name: Set up Python 3.12
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: "3.12"
24+
- name: Install pypa/build
25+
run: pip install --constraint=.github/workflows/constraints.txt pip uv
26+
- name: Build a binary wheel and a source tarball
27+
run: uv build spiff-arena-common
28+
- name: Publish distribution 📦 to PyPI
29+
if: github.ref == 'refs/heads/main'
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
user: __token__
33+
password: ${{ secrets.COMMON_PYPI_KEY }}

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Get SHA for workflow_run
1616
id: get_sha
1717
if: github.event_name == 'workflow_run'
18-
run: echo "sha=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_OUTPUT
18+
run: echo "sha=${{ github.event.workflow_run.head_sha }}" >> "$GITHUB_OUTPUT"
1919

2020
- name: Checkout
2121
uses: actions/checkout@v6

0 commit comments

Comments
 (0)