Skip to content

Commit a6fd678

Browse files
author
Gonzalo Diaz
committed
[CONFIG] [Gihub Actions] Docker running in splitted jobs.
1 parent a08b5ea commit a6fd678

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

.github/workflows/docker-image.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on: # yamllint disable-line rule:truthy
1010

1111
env:
1212
IMAGE_NAME: algorithm-exercises-js
13+
ARTIFACT_NAME: algorithm-exercises-js_${{ github.sha }}
1314

1415
jobs:
1516
security:
@@ -60,60 +61,62 @@ jobs:
6061
context: .
6162
target: lint
6263
outputs: |
63-
type=docker,dest=/tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_lint.tar
64+
type=docker,dest=/tmp/${{ env.ARTIFACT_NAME }}_lint.tar
6465
tags: |
6566
${{ env.IMAGE_NAME }}:lint
6667
- name: "LINT: Upload artifact"
6768
uses: actions/upload-artifact@v4
6869
with:
69-
name: ${{ env.IMAGE_NAME }}_${{ github.sha }}_lint
70-
path: /tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_lint.tar
70+
name: ${{ env.ARTIFACT_NAME }}_lint
71+
path: /tmp/${{ env.ARTIFACT_NAME }}_lint.tar
7172

7273
- name: "TEST: Build and push"
7374
uses: docker/build-push-action@v6
7475
with:
7576
context: .
7677
target: testing
7778
outputs: |
78-
type=docker,dest=/tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_test.tar
79+
type=docker,dest=/tmp/${{ env.ARTIFACT_NAME }}_test.tar
7980
tags: |
8081
${{ env.IMAGE_NAME }}:test
8182
- name: "TEST: Upload artifact"
8283
uses: actions/upload-artifact@v4
8384
with:
84-
name: ${{ env.IMAGE_NAME }}_${{ github.sha }}_test
85-
path: /tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_test.tar
85+
name: ${{ env.ARTIFACT_NAME }}_test
86+
path: /tmp/${{ env.ARTIFACT_NAME }}_test.tar
8687

8788
- name: "PRODUCTION: Build and push"
8889
uses: docker/build-push-action@v6
8990
with:
9091
context: .
9192
target: production
9293
outputs: |
93-
type=docker,dest=/tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_prod.tar
94+
type=docker,dest=/tmp/${{ env.ARTIFACT_NAME }}_prod.tar
9495
tags: |
9596
${{ env.IMAGE_NAME }}:latest
9697
${{ env.IMAGE_NAME }}:${{ github.sha }}
9798
- name: "PRODUCTION: Upload artifact"
9899
uses: actions/upload-artifact@v4
99100
with:
100-
name: ${{ env.IMAGE_NAME }}_${{ github.sha }}_prod
101-
path: /tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_prod.tar
101+
name: ${{ env.ARTIFACT_NAME }}_prod
102+
path: /tmp/${{ env.ARTIFACT_NAME }}_prod.tar
102103

103104
lint:
104105
name: "Run in docker: LINT"
105106
runs-on: ubuntu-latest
106107
needs: build
107108
steps:
109+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
110+
108111
- name: Download artifact
109112
uses: actions/download-artifact@v4
110113
with:
111-
name: ${{ env.IMAGE_NAME }}_${{ github.sha }}_prod
114+
name: ${{ env.ARTIFACT_NAME }}_prod
112115
path: /tmp/
113116

114117
- name: Load image
115118
run: |
116-
docker load --input /tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_prod.tar
119+
docker load --input /tmp/${{ env.ARTIFACT_NAME }}_prod.tar
117120
docker image ls -a
118121
119122
- name: Run lint
@@ -128,12 +131,12 @@ jobs:
128131
- name: Download artifact
129132
uses: actions/download-artifact@v4
130133
with:
131-
name: ${{ env.IMAGE_NAME }}_${{ github.sha }}_prod
134+
name: ${{ env.ARTIFACT_NAME }}_prod
132135
path: /tmp/
133136

134137
- name: Load image
135138
run: |
136-
docker load --input /tmp/${{ env.IMAGE_NAME }}_${{ github.sha }}_prod.tar
139+
docker load --input /tmp/${{ env.ARTIFACT_NAME }}_prod.tar
137140
docker image ls -a
138141
139142
- name: Run Trivy vulnerability scanner

0 commit comments

Comments
 (0)