Skip to content

Commit f315732

Browse files
committed
Switch to buildx to create sbom.
1 parent a61533c commit f315732

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
packages: write
4747
contents: write
4848
outputs:
49-
api_image: ${{steps.build_image.outputs.api_image}}
49+
api_image: ${{steps.set_image.outputs.api_image}}
5050
migration_image: ${{steps.migration-publish.outputs.image}}
5151
steps:
5252
- name: checkout code
@@ -64,7 +64,10 @@ jobs:
6464
run: echo "VERSION=${{inputs.branch}}-nightly" >> $GITHUB_ENV
6565
- name: Set version
6666
if: inputs.nightly == false
67-
run: echo "VERSION=${{inputs.branch}}" >> $GITHUB_ENV
67+
run: |
68+
echo "VERSION=${{inputs.branch}}" >> $GITHUB_ENV
69+
REPO=`echo "${{github.repository}}" | tr '[:upper:]' '[:lower:]'`
70+
echo "REPO=$REPO" >> $GITHUB_ENV
6871
- name: show version
6972
run: echo ${VERSION}
7073
- name: build war
@@ -77,6 +80,19 @@ jobs:
7780
tag_name: ${{env.VERSION}}
7881
generate_release_notes: true
7982
token: ${{ secrets.token != null && secrets.token || secrets.GITHUB_TOKEN }}
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v3.10.0
85+
- name: Docker meta
86+
id: meta
87+
uses: docker/metadata-action@v5.7.0
88+
with:
89+
images: |
90+
${{secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY}}/cwms/data-api
91+
ghcr.io/${REPO}
92+
tags: |
93+
type=sha
94+
type=ref,event=tag
95+
type=schedule,pattern=nightly
8096
- name: Log in to the Container registry
8197
id: login-ghcr
8298
uses: docker/login-action@v3.3.0
@@ -91,21 +107,15 @@ jobs:
91107
registry: ${{ secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY }}
92108
username: ${{ secrets.registry_user != null && secrets.registry_user || secrets.ALT_REG_USER }}
93109
password: ${{ secrets.registry_password != null && secrets.registry_password || secrets.ALT_REG_PASSWORD }}
94-
- name: Build docker image
95-
id: build_image
96-
env:
97-
IMAGE_TAG: ${{env.VERSION}}
98-
ALT_REGISTRY: ${{secrets.ALT_REGISTRY}}
99-
HEC_PUB_REGISTRY: ${{secrets.HEC_PUB_REGISTRY}}
110+
- name: Build and push
111+
uses: docker/build-push-action@v6.16.0
112+
with:
113+
push: true
114+
tags: ${{ steps.meta.outputs.tags }}
115+
labels: ${{ steps.meta.outputs.labels }}
116+
- name: Set Output Image
117+
id: set_image
100118
run: |
101-
HEC_PUB_REGISTRY="${{secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY}}"
102-
REPO=`echo "${{github.repository}}" | tr '[:upper:]' '[:lower:]'`
103-
echo "REPO=$REPO" >> $GITHUB_ENV
104-
docker build -t cda:build-latest .
105-
docker tag cda:build-latest ghcr.io/${REPO}:$VERSION
106-
docker tag cda:build-latest $HEC_PUB_REGISTRY/cwms/data-api:$VERSION
107-
docker push $HEC_PUB_REGISTRY/cwms/data-api:$VERSION
108-
docker push ghcr.io/${REPO}:$VERSION
109119
echo "api_image=ghcr.io/${REPO}:$VERSION" >> $GITHUB_OUTPUT
110120
- name: Setup Database Migration Image
111121
id: migration

0 commit comments

Comments
 (0)