Skip to content

Commit 39aa912

Browse files
committed
fix: Normalize repository and owner names in Docker workflow
Introduced a step to standardize repository and owner names by converting them to lowercase and applying kebab-case to the repository name. Updated subsequent steps to use these normalized names for Docker image tagging and pushing. This ensures consistency and avoids potential naming issues.
1 parent 8904fc2 commit 39aa912

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

.github/workflows/deploy.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,35 @@ jobs:
2222
node-version: 22
2323
cache: "yarn"
2424

25-
# 3. Docker にログイン(GitHub Container Registry)
25+
# 3. リポジトリ名と所有者名を変換
26+
- name: Normalize Names
27+
id: normalize-names
28+
run: |
29+
# ユーザー名を小文字に変換
30+
NORMALIZED_OWNER_NAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
31+
32+
# リポジトリ名をケバブケースに変換
33+
NORMALIZED_REPOSITORY_NAME=$(echo "${{ github.repository }}" | sed -E 's/([a-z])([A-Z])/\1-\L\2/g' | tr '[:upper:]' '[:lower:]')
34+
35+
# 正規化した結果を出力(後続ステップで利用可能)
36+
echo "NORMALIZED_OWNER_NAME=${NORMALIZED_OWNER_NAME}" >> $GITHUB_ENV
37+
echo "NORMALIZED_REPOSITORY_NAME=${NORMALIZED_REPOSITORY_NAME}" >> $GITHUB_ENV
38+
39+
# 4. Docker にログイン(GitHub Container Registry)
2640
- name: Log in to GitHub Container Registry
2741
uses: docker/[email protected]
2842
with:
2943
registry: ghcr.io
30-
username: ${{ github.repository_owner }}
44+
username: ${{ env.NORMALIZED_OWNER_NAME }}
3145
password: ${{ secrets.GITHUB_TOKEN }}
3246

33-
# 4. Docker イメージをビルド
47+
# 5. Docker イメージをビルド
3448
- name: Build Docker Image
3549
run: |
3650
docker build -f infra/docker/Dockerfile . \
37-
-t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
51+
-t ghcr.io/${{ env.NORMALIZED_OWNER_NAME }}/${{ env.NORMALIZED_REPOSITORY_NAME }}:latest
3852
39-
# 5. Docker イメージをプッシュ
53+
# 6. Docker イメージをプッシュ
4054
- name: Push Docker Image
4155
run: |
42-
docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
56+
docker push ghcr.io/${{ env.NORMALIZED_OWNER_NAME }}/${{ env.NORMALIZED_REPOSITORY_NAME }}:latest

0 commit comments

Comments
 (0)