Skip to content

Commit c46a4b6

Browse files
author
valhassan
committed
Update GitHub Actions workflow to enhance Docker image build process by upgrading action versions, consolidating build and push steps, and improving metadata extraction for tags and labels.
1 parent 7b8a995 commit c46a4b6

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

.github/workflows/build-on-tag.yml

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Build Docker Image on Tag (CUDA 12)
32

43
on:
@@ -10,39 +9,33 @@ env:
109
REGISTRY: docker.io
1110

1211
jobs:
13-
1412
build:
15-
1613
runs-on: ubuntu-latest
17-
1814
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v3
21-
22-
- name: Log in to the Container registry
23-
uses: docker/login-action@v2
24-
with:
25-
registry: docker.io
26-
username: ${{ secrets.DOCKER_USER }}
27-
password: ${{ secrets.DOCKER_PASSWORD }}
28-
29-
- name: Extract metadata (tags, labels) for Docker
30-
id: meta
31-
uses: docker/metadata-action@v4
32-
with:
33-
images: ${{ env.REGISTRY }}/${{ secrets.DOCKER_REPO }}
34-
35-
- name: Build the docker image
36-
run: docker build . --file Dockerfile --tag gdl-cuda12:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} --build-arg GIT_TAG=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
37-
38-
- name: Tag the docker image
39-
run: docker tag gdl-cuda12:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} ${{ secrets.DOCKER_REPO }}/gdl-cuda12:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
40-
41-
- name: Push the docker image
42-
run: docker push ${{ secrets.DOCKER_REPO }}/gdl-cuda12:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
43-
44-
- name: Tag the docker image to latest
45-
run: docker tag gdl-cuda12:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} ${{ secrets.DOCKER_REPO }}/gdl-cuda12:latest
46-
47-
- name: Push the docker image (latest tag)
48-
run: docker push ${{ secrets.DOCKER_REPO }}/gdl-cuda12:latest
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Log in to Container registry
19+
uses: docker/login-action@v3
20+
with:
21+
registry: docker.io
22+
username: ${{ secrets.DOCKER_USER }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
25+
- name: Extract metadata (tags, labels) for Docker
26+
id: meta
27+
uses: docker/metadata-action@v4
28+
with:
29+
images: ${{ env.REGISTRY }}/${{ secrets.DOCKER_REPO }}/gdl-cuda12
30+
tags: |
31+
type=ref,event=tag
32+
type=raw,value=latest,enable=true
33+
34+
- name: Build and push Docker image
35+
uses: docker/build-push-action@v6
36+
with:
37+
context: .
38+
file: ./Dockerfile
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)