Skip to content

Commit 28e6d01

Browse files
committed
Lowercase repository owner in GitHub Actions for consistent image naming
1 parent 0b4799f commit 28e6d01

2 files changed

Lines changed: 30 additions & 25 deletions

File tree

.github/workflows/build-backend.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ jobs:
5656
echo "tag=${TAG}" >> $GITHUB_OUTPUT
5757
echo "Image will be tagged as: ${TAG}"
5858
59-
# Step 3: Log into GitHub Container Registry
59+
# Step 3: Lowercase the repository owner
60+
# GHCR requires all image names to be lowercase
61+
# github.repository_owner may have uppercase letters (e.g. ShashankPgit)
62+
- name: Set lowercase owner
63+
id: owner
64+
run: echo "value=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
65+
66+
# Step 4: Log into GitHub Container Registry
6067
# GITHUB_TOKEN is automatic — GitHub creates it for every workflow run
6168
# It has permission to push packages for this repo without any manual setup
6269
- name: Login to GitHub Container Registry
@@ -66,29 +73,26 @@ jobs:
6673
username: ${{ github.actor }}
6774
password: ${{ secrets.GITHUB_TOKEN }}
6875

69-
# Step 4: Set up Docker Buildx (enables multi-platform builds + better caching)
76+
# Step 5: Set up Docker Buildx (enables multi-platform builds + better caching)
7077
- name: Set up Docker Buildx
7178
uses: docker/setup-buildx-action@v3
7279

73-
# Step 5: Build the backend Docker image and push to GHCR
74-
# context: the directory sent to Docker as the build context
75-
# tags: we push two tags — the specific version tag + "latest"
80+
# Step 6: Build the backend Docker image and push to GHCR
7681
- name: Build and push
7782
uses: docker/build-push-action@v5
7883
with:
7984
context: ./vault/backend
8085
file: ./vault/backend/Dockerfile
8186
push: true
8287
tags: |
83-
ghcr.io/${{ github.repository_owner }}/vault-api:${{ steps.tag.outputs.tag }}
84-
ghcr.io/${{ github.repository_owner }}/vault-api:latest
85-
# Cache layers from the previous build to speed up future builds
88+
ghcr.io/${{ steps.owner.outputs.value }}/vault-api:${{ steps.tag.outputs.tag }}
89+
ghcr.io/${{ steps.owner.outputs.value }}/vault-api:latest
8690
cache-from: type=gha
8791
cache-to: type=gha,mode=max
8892

89-
# Step 6: Print a summary so it's easy to see what was pushed
93+
# Step 7: Print a summary so it's easy to see what was pushed
9094
- name: Print image details
9195
run: |
9296
echo "✅ Image pushed successfully"
93-
echo "📦 ghcr.io/${{ github.repository_owner }}/vault-api:${{ steps.tag.outputs.tag }}"
94-
echo "📦 ghcr.io/${{ github.repository_owner }}/vault-api:latest"
97+
echo "📦 ghcr.io/${{ steps.owner.outputs.value }}/vault-api:${{ steps.tag.outputs.tag }}"
98+
echo "📦 ghcr.io/${{ steps.owner.outputs.value }}/vault-api:latest"

.github/workflows/build-frontend.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,40 +57,41 @@ jobs:
5757
echo "tag=${TAG}" >> $GITHUB_OUTPUT
5858
echo "Image will be tagged as: ${TAG}"
5959
60-
# Step 3: Log into GitHub Container Registry
60+
# Step 3: Lowercase the repository owner
61+
- name: Set lowercase owner
62+
id: owner
63+
run: echo "value=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
64+
65+
# Step 4: Log into GitHub Container Registry
6166
- name: Login to GitHub Container Registry
6267
uses: docker/login-action@v3
6368
with:
6469
registry: ghcr.io
6570
username: ${{ github.actor }}
6671
password: ${{ secrets.GITHUB_TOKEN }}
6772

68-
# Step 4: Set up Docker Buildx
73+
# Step 5: Set up Docker Buildx
6974
- name: Set up Docker Buildx
7075
uses: docker/setup-buildx-action@v3
7176

72-
# Step 5: Build the frontend image and push to GHCR
73-
# The nginx Dockerfile does two things:
74-
# - builds the React app (using node:22-slim as builder)
75-
# - copies the built files into nginx:alpine to serve them
76-
# So the build context must be ./vault (parent of both frontend/ and nginx/)
77-
# because the Dockerfile references both directories
77+
# Step 6: Build the frontend image and push to GHCR
78+
# context must be ./vault (parent of both frontend/ and nginx/)
79+
# because the Dockerfile copies from both directories
7880
- name: Build and push
7981
uses: docker/build-push-action@v5
8082
with:
8183
context: ./vault
8284
file: ./vault/nginx/Dockerfile
8385
push: true
8486
tags: |
85-
ghcr.io/${{ github.repository_owner }}/vault-nginx:${{ steps.tag.outputs.tag }}
86-
ghcr.io/${{ github.repository_owner }}/vault-nginx:latest
87-
# Cache layers from the previous build to speed up future builds
87+
ghcr.io/${{ steps.owner.outputs.value }}/vault-nginx:${{ steps.tag.outputs.tag }}
88+
ghcr.io/${{ steps.owner.outputs.value }}/vault-nginx:latest
8889
cache-from: type=gha
8990
cache-to: type=gha,mode=max
9091

91-
# Step 6: Print a summary
92+
# Step 7: Print a summary
9293
- name: Print image details
9394
run: |
9495
echo "✅ Image pushed successfully"
95-
echo "📦 ghcr.io/${{ github.repository_owner }}/vault-nginx:${{ steps.tag.outputs.tag }}"
96-
echo "📦 ghcr.io/${{ github.repository_owner }}/vault-nginx:latest"
96+
echo "📦 ghcr.io/${{ steps.owner.outputs.value }}/vault-nginx:${{ steps.tag.outputs.tag }}"
97+
echo "📦 ghcr.io/${{ steps.owner.outputs.value }}/vault-nginx:latest"

0 commit comments

Comments
 (0)