Skip to content

Commit 98bc41b

Browse files
ifs on cicd
1 parent 102f82a commit 98bc41b

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

.github/workflows/cicd.yaml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,35 @@ jobs:
8989
- name: Checkout repository
9090
uses: actions/checkout@v5
9191
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
92-
- name: Log in to the Container registry
93-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
94-
with:
95-
registry: ${{ env.registry }}
96-
username: ${{ github.actor }}
97-
password: ${{ secrets.GITHUB_TOKEN }}
92+
9893
- uses: dorny/paths-filter@v3
9994
id: changes
10095
with:
10196
filters: |
10297
src:
10398
- '${{env.base_dir}}/${{ matrix.container_name }}/**'
99+
100+
- if: steps.changes.outputs.src == 'true'
101+
name: Log in to the Container registry
102+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
103+
with:
104+
registry: ${{ env.registry }}
105+
username: ${{ github.actor }}
106+
password: ${{ secrets.GITHUB_TOKEN }}
107+
104108
- if: steps.changes.outputs.src == 'true'
105109
uses: actions/setup-node@v6
106110
with:
107111
node-version: ${{ env.node_version }}
108112

109-
- name: Build
113+
- if: steps.changes.outputs.src == 'true'
114+
name: Build
110115
working-directory: ${{env.base_dir}}/${{ matrix.container_name }}
111116
run: |
112117
make build IMAGE_NAME=${{ env.registry }}/${{ matrix.image }} WORKSPACE_FOLDER=${{ env.workspace_folder }}
113118
114-
115-
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
116-
- name: Extract metadata (tags, labels) for Docker
119+
- if: steps.changes.outputs.src == 'true'
120+
name: Extract metadata (tags, labels) for Docker
117121
id: meta
118122
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
119123
with:
@@ -136,11 +140,12 @@ jobs:
136140
org.opencontainers.image.url=${{ env.server }}/${{ env.org }}/${{ env.repository }}/blob/main/${{ env.base_dir }}/${{matrix.container_name}}/${{ env.readme }}
137141
org.opencontainers.image.source=${{ env.server }}/${{ env.org }}/${{ env.repository }}/tree/main/${{ env.base_dir }}/${{matrix.container_name}}/
138142
139-
# So we don't rebuild the container image, we create a simple Dockerfile that uses the previously built image as its source.
140-
- name: create temp dockerfile source
143+
- if: steps.changes.outputs.src == 'true'
144+
name: create temp dockerfile source
141145
run: echo 'FROM ${{ env.registry }}/${{ matrix.image }}' > ${{ env.temp_dockerfile }}
142146

143-
- name: Build and push Docker image
147+
- if: steps.changes.outputs.src == 'true'
148+
name: Build and push Docker image
144149
id: push
145150
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
146151
with:
@@ -150,8 +155,8 @@ jobs:
150155
tags: ${{ steps.meta.outputs.tags }}
151156
labels: ${{ steps.meta.outputs.labels }}
152157

153-
# 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 [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
154-
- name: Generate artifact attestation
158+
- if: steps.changes.outputs.src == 'true'
159+
name: Generate artifact attestation
155160
uses: actions/attest-build-provenance@v3
156161
with:
157162
subject-name: ${{ env.registry }}/${{ matrix.image }}

0 commit comments

Comments
 (0)