Skip to content

Commit f9025c1

Browse files
authored
chore: rename container script (#277)
* chore: rename container script Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: suffix -dev for non release images Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: use commit sha for image tagging Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: use commit sha for image tagging Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: use -ea.COMMIT_SHA suffix Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: no need to restore the version Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> * chore: remove unused trigger and make conditions safer Signed-off-by: Ruben Romero Montes <rromerom@redhat.com> --------- Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 7da70aa commit f9025c1

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ on:
77
workflows: ["Integration Tests"]
88
types:
99
- completed
10-
branches:
11-
- main
1210
push:
1311
tags:
1412
- 'v*.*.*'
15-
- '*.*.*'
1613

1714
permissions:
1815
contents: write
@@ -22,8 +19,8 @@ jobs:
2219
publish-ea:
2320
if: |
2421
github.event_name == 'workflow_run' &&
25-
github.event.workflow_run.head_branch == 'main' &&
26-
github.event.workflow_run.event == 'push'
22+
github.event.workflow_run.event == 'push' &&
23+
github.event.workflow_run.head_branch == 'main'
2724
runs-on: ubuntu-latest
2825
name: Publish EA release to NPM
2926
steps:
@@ -70,11 +67,8 @@ jobs:
7067
run: |
7168
SHORT_SHA=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}")
7269
EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea.${SHORT_SHA}"
73-
# Temporarily update version for publish
7470
npm version "$EA_VERSION" --no-git-tag-version
7571
npm publish --verbose --tag ea --access public --provenance
76-
# Restore original version
77-
npm version "${{ steps.current-version.outputs.base-version }}" --no-git-tag-version
7872
7973
publish-release:
8074
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

.github/workflows/push-to-registry.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
name: Push to registry
44

55
on:
6+
workflow_run:
7+
workflows: ["Integration Tests"]
8+
types:
9+
- completed
610
push:
7-
branches:
8-
- main
9-
- 'release/*'
1011
tags:
11-
- '*'
12+
- 'v*.*.*'
1213
workflow_dispatch:
1314

1415
env:
@@ -17,6 +18,19 @@ env:
1718

1819
jobs:
1920
build-and-push:
21+
if: |
22+
(
23+
github.event_name == 'workflow_run' &&
24+
github.event.workflow_run.event == 'push' &&
25+
github.event.workflow_run.head_branch == 'main'
26+
)
27+
||
28+
(
29+
github.event_name == 'push' &&
30+
startsWith(github.ref, 'refs/tags/')
31+
)
32+
||
33+
github.event_name == 'workflow_dispatch'
2034
runs-on: ubuntu-latest
2135
permissions:
2236
contents: read
@@ -38,19 +52,26 @@ jobs:
3852
- name: Compile project
3953
run: npm run compile
4054

41-
- name: Get package version
42-
id: package-version
55+
- name: Determine package version
56+
id: version
4357
run: |
44-
# Use git tag if available (for tag-triggered builds), otherwise use package.json
45-
if [ -n "${{ github.ref_type }}" ] && [ "${{ github.ref_type }}" = "tag" ]; then
46-
# Remove 'v' prefix if present (e.g., v1.0.0 -> 1.0.0)
47-
VERSION="${{ github.ref_name }}"
48-
VERSION="${VERSION#v}"
58+
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [[ "${GITHUB_REF}" =~ refs/tags/ ]]; then
59+
# Release tag
60+
VERSION="${GITHUB_REF#refs/tags/v}"
61+
EA_BUILD=false
62+
elif [ "${GITHUB_REF}" = "refs/heads/main" ]; then
63+
# EA build for main
64+
BASE=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//')
65+
SHORT_SHA=$(git rev-parse --short "${GITHUB_SHA}")
66+
VERSION="${BASE}-ea.${SHORT_SHA}"
67+
EA_BUILD=true
4968
else
50-
VERSION=$(node -p "require('./package.json').version")
69+
echo "Not building image for this branch"
70+
exit 0
5171
fi
72+
5273
echo "version=$VERSION" >> $GITHUB_OUTPUT
53-
echo "Package version: $VERSION"
74+
echo "ea_build=$EA_BUILD" >> $GITHUB_OUTPUT
5475
5576
- name: Get image metadata
5677
id: image-meta
@@ -68,14 +89,14 @@ jobs:
6889
username: ${{ github.actor }}
6990
password: ${{ secrets.GITHUB_TOKEN }}
7091

71-
- name: Extract metadata (tags, labels) for Docker
92+
- name: Extract Docker metadata
7293
id: meta
7394
uses: docker/metadata-action@v5
7495
with:
7596
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7697
tags: |
77-
type=raw,value=latest,enable={{is_default_branch}}
78-
type=raw,value=${{ steps.package-version.outputs.version }}
98+
type=raw,value=latest,enable=${{ steps.version.outputs.ea_build == 'true' }}
99+
type=raw,value=${{ steps.version.outputs.version }}
79100
80101
- name: Build and push Docker image
81102
uses: docker/build-push-action@v5

docker-image/Dockerfiles/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN curl -kL https://go.dev/dl/go1.21.5.linux-amd64.tar.gz -o /tmp/golang-packag
2020
RUN curl -kL https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux64 -o /usr/bin/jq
2121

2222
# Copy RHDA script (before changing WORKDIR)
23-
COPY docker-image/scripts/rhda.sh /rhda.sh
23+
COPY docker-image/scripts/trustify-da.sh /trustify-da.sh
2424

2525
# Copy project files and install Exhort javascript API locally
2626
WORKDIR /app
@@ -38,7 +38,7 @@ RUN chmod +x /usr/jdk-21.0.1/bin/java \
3838
&& chmod +x /usr/bin/jq \
3939
&& chmod +x /app/dist/src/cli.js \
4040
&& chmod +x /app/node_modules/.bin/trustify-da-javascript-client \
41-
&& chmod +x /rhda.sh
41+
&& chmod +x /trustify-da.sh
4242

4343
# use default user
4444
USER default
@@ -91,5 +91,5 @@ COPY --from=builder /usr/bin/jq /usr/bin/jq
9191
# Copy trustify-da-javascript-client from the builder stage
9292
COPY --from=builder /app /app
9393

94-
# Copy RHDA executable script from the builder stage
95-
COPY --from=builder /rhda.sh /rhda.sh
94+
# Copy trustify-da-javascript-client executable script from the builder stage
95+
COPY --from=builder /trustify-da.sh /trustify-da.sh

0 commit comments

Comments
 (0)