Skip to content

Commit 8f6d429

Browse files
authored
Merge pull request #15 from yiliuTo/modify-tags
Change the tag schema and image infix
2 parents c72fc68 + 228823a commit 8f6d429

File tree

2 files changed

+30
-43
lines changed

2 files changed

+30
-43
lines changed

.github/workflows/build-publish-petclinic-images.yml

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ on:
99
inputs:
1010
petclinic_repo_url:
1111
description: 'The repository url of Spring Petclinic microservices'
12-
required: true
1312
default: 'https://github.com/spring-petclinic/spring-petclinic-microservices.git'
13+
image_tag_version:
14+
description: 'The image tag version of Spring Petclinic microservices, default is the github run id + run_attempt'
1415

1516
defaults:
1617
run:
@@ -19,11 +20,12 @@ defaults:
1920

2021
env:
2122
REGISTRY: ghcr.io
22-
IMAGE_PREFIX: ${{ github.repository_owner }}
23+
IMAGE_INFIX: ${{ github.repository_owner }}/javaaccelerator
2324
CUSTOMERS_SERVICE: spring-petclinic-customers-service
2425
VETS_SERVICE: spring-petclinic-vets-service
2526
VISITS_SERVICE: spring-petclinic-visits-service
2627
API_GATEWAY: spring-petclinic-api-gateway
28+
TAG_VERSION: ${{ inputs.image_tag_version != '' && inputs.image_tag_version || format('{0}{1}', github.run_id, github.run_attempt) }}
2729

2830
jobs:
2931
build-and-push-image:
@@ -61,7 +63,10 @@ jobs:
6163
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
6264
with:
6365
images: |
64-
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.CUSTOMERS_SERVICE }}
66+
${{ env.REGISTRY }}/${{ env.IMAGE_INFIX }}/${{ env.CUSTOMERS_SERVICE }}
67+
tags: |
68+
type=raw,value=latest
69+
type=raw,value=${{ env.TAG_VERSION }}
6570
- name: Build and push customers-service image
6671
id: push-customers
6772
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -71,19 +76,15 @@ jobs:
7176
push: true
7277
tags: ${{ steps.meta-customers.outputs.tags }}
7378
build-args: ARTIFACT_NAME=${{ env.CUSTOMERS_SERVICE }}
74-
- name: Generate artifact attestation for customers-service
75-
id: attest-customers
76-
uses: actions/attest-build-provenance@v1
77-
with:
78-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.CUSTOMERS_SERVICE }}
79-
subject-digest: ${{ steps.push-customers.outputs.digest }}
80-
push-to-registry: true
8179
- name: Extract metadata (tags, labels) for vets-service
8280
id: meta-vets
8381
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
8482
with:
8583
images: |
86-
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.VETS_SERVICE }}
84+
${{ env.REGISTRY }}/${{ env.IMAGE_INFIX }}/${{ env.VETS_SERVICE }}
85+
tags: |
86+
type=raw,value=latest
87+
type=raw,value=${{ env.TAG_VERSION }}
8788
- name: Build and push vets-service image
8889
id: push-vets
8990
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -93,19 +94,15 @@ jobs:
9394
push: true
9495
tags: ${{ steps.meta-vets.outputs.tags }}
9596
build-args: ARTIFACT_NAME=${{ env.VETS_SERVICE }}
96-
- name: Generate artifact attestation for vets-service
97-
id: attest-vets
98-
uses: actions/attest-build-provenance@v1
99-
with:
100-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.VETS_SERVICE }}
101-
subject-digest: ${{ steps.push-vets.outputs.digest }}
102-
push-to-registry: true
10397
- name: Extract metadata (tags, labels) for visits-service
10498
id: meta-visits
10599
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
106100
with:
107101
images: |
108-
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.VISITS_SERVICE }}
102+
${{ env.REGISTRY }}/${{ env.IMAGE_INFIX }}/${{ env.VISITS_SERVICE }}
103+
tags: |
104+
type=raw,value=latest
105+
type=raw,value=${{ env.TAG_VERSION }}
109106
- name: Build and push visits-service image
110107
id: push-visits
111108
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -115,19 +112,15 @@ jobs:
115112
push: true
116113
tags: ${{ steps.meta-visits.outputs.tags }}
117114
build-args: ARTIFACT_NAME=${{ env.VISITS_SERVICE }}
118-
- name: Generate artifact attestation for visits-service
119-
id: attest-visits
120-
uses: actions/attest-build-provenance@v1
121-
with:
122-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.VISITS_SERVICE }}
123-
subject-digest: ${{ steps.push-visits.outputs.digest }}
124-
push-to-registry: true
125115
- name: Extract metadata (tags, labels) for api-gateway
126116
id: meta-api
127117
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
128118
with:
129119
images: |
130-
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.API_GATEWAY }}
120+
${{ env.REGISTRY }}/${{ env.IMAGE_INFIX }}/${{ env.API_GATEWAY }}
121+
tags: |
122+
type=raw,value=latest
123+
type=raw,value=${{ env.TAG_VERSION }}
131124
- name: Build and push api-gateway image
132125
id: push-api
133126
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -139,10 +132,3 @@ jobs:
139132
build-args: |
140133
ARTIFACT_NAME=${{ env.API_GATEWAY }}
141134
EXPOSED_PORT=8080
142-
- name: Generate artifact attestation for api-gateway
143-
id: attest-api
144-
uses: actions/attest-build-provenance@v1
145-
with:
146-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.API_GATEWAY }}
147-
subject-digest: ${{ steps.push-api.outputs.digest }}
148-
push-to-registry: true

.github/workflows/build-publish-springbatch-football-image.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ name: Publish SpringBatch Football images
66

77
on:
88
workflow_dispatch:
9+
inputs:
10+
image_tag_version:
11+
description: 'The image tag version of Spring batch football, default is the github run id + run_attempt'
12+
913

1014
defaults:
1115
run:
@@ -14,8 +18,9 @@ defaults:
1418

1519
env:
1620
REGISTRY: ghcr.io
17-
IMAGE_PREFIX: ${{ github.repository_owner }}
21+
IMAGE_INFIX: ${{ github.repository_owner }}/javaaccelerator
1822
IMAGE_NAME: spring-batch-football
23+
TAG_VERSION: ${{ inputs.image_tag_version != '' && inputs.image_tag_version || format('{0}{1}', github.run_id, github.run_attempt) }}
1924

2025
jobs:
2126
build-and-push-image:
@@ -48,7 +53,10 @@ jobs:
4853
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
4954
with:
5055
images: |
51-
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.IMAGE_NAME }}
56+
${{ env.REGISTRY }}/${{ env.IMAGE_INFIX }}/${{ env.IMAGE_NAME }}
57+
tags: |
58+
type=raw,value=latest
59+
type=raw,value=${{ env.TAG_VERSION }}
5260
- name: Build and push image
5361
id: push-image
5462
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -57,10 +65,3 @@ jobs:
5765
file: spring-batch-football/Dockerfile
5866
push: true
5967
tags: ${{ steps.meta-image.outputs.tags }}
60-
- name: Generate artifact attestation
61-
id: attest-image
62-
uses: actions/attest-build-provenance@v1
63-
with:
64-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ env.IMAGE_NAME }}
65-
subject-digest: ${{ steps.push-image.outputs.digest }}
66-
push-to-registry: true

0 commit comments

Comments
 (0)