Skip to content

Commit bc28a25

Browse files
committed
Bug fix in CD process using GitHub registry
1 parent 64c45b5 commit bc28a25

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

.github/workflows/publish-docker-image.yml

+21-14
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,49 @@ jobs:
2727
uses: actions/checkout@v4
2828

2929
- name: Log in to the Container registry
30-
uses: docker/login-action@v2
30+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
3131
with:
3232
registry: ${{ env.REGISTRY }}
3333
username: ${{ github.actor }}
3434
password: ${{ secrets.GITHUB_TOKEN }}
35-
35+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels.
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
42+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
43+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
3644
- name: Build and push backend Docker image
45+
id: push
3746
uses: docker/build-push-action@v3
3847
with:
3948
context: ./backend
4049
push: true
41-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/karevo-dashboard-backend:latest
42-
labels: |
43-
org.opencontainers.image.source=${{ github.repository }}
44-
org.opencontainers.image.version=${{ github.sha }}
50+
tags: ${{ steps.meta.outputs.tags }}
51+
labels: ${{ steps.meta.outputs.labels }}
4552

4653
- name: Build and push frontend Docker image
54+
id: push
4755
uses: docker/build-push-action@v3
4856
with:
4957
context: ./frontend
5058
push: true
51-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/karevo-dashboard-frontend:latest
52-
labels: |
53-
org.opencontainers.image.source=${{ github.repository }}
54-
org.opencontainers.image.version=${{ github.sha }}
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
5561

62+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
5663
- name: Generate artifact attestation for backend
5764
uses: actions/attest-build-provenance@v1
5865
with:
59-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/karevo-dashboard-backend:latest
60-
subject-digest: ${{ steps.backend_push.outputs.digest }}
66+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}/backend
67+
subject-digest: ${{ steps.push.outputs.digest }}
6168
push-to-registry: true
6269

6370
- name: Generate artifact attestation for frontend
6471
uses: actions/attest-build-provenance@v1
6572
with:
66-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/karevo-dashboard-frontend:latest
67-
subject-digest: ${{ steps.frontend_push.outputs.digest }}
73+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}/frontend
74+
subject-digest: ${{ steps.push.outputs.digest }}
6875
push-to-registry: true

docker-compose.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: '3.8'
33
services:
44
backend:
55
build: ./backend
6-
image: dpidkarevo2024/karevo-dashboard-api:latest
76
container_name: karevo-dashboard-api
87
ports:
98
- '8080:8080'
@@ -20,7 +19,6 @@ services:
2019

2120
frontend:
2221
build: ./frontend
23-
image: dpidkarevo2024/karevo-dashboard-frontend:latest
2422
container_name: karevo-dashboard-web
2523
ports:
2624
- '3000:3000'

0 commit comments

Comments
 (0)