Skip to content

Commit 09be744

Browse files
committed
chore: remove unused trigger and make conditions safer
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent e4f62c2 commit 09be744

2 files changed

Lines changed: 33 additions & 30 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 5 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:

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

Lines changed: 31 additions & 25 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
workflow_dispatch:
1714

1815
env:
@@ -22,9 +19,18 @@ env:
2219
jobs:
2320
build-and-push:
2421
if: |
25-
github.event_name == 'workflow_run' &&
26-
github.event.workflow_run.head_branch == 'main' &&
27-
github.event.workflow_run.event == 'push'
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'
2834
runs-on: ubuntu-latest
2935
permissions:
3036
contents: read
@@ -46,26 +52,26 @@ jobs:
4652
- name: Compile project
4753
run: npm run compile
4854

49-
- name: Get package version
50-
id: package-version
55+
- name: Determine package version
56+
id: version
5157
run: |
52-
# Use git tag if available (for tag-triggered builds), otherwise use base version with -ea.COMMIT_SHA suffix
53-
if [ -n "${{ github.ref_type }}" ] && [ "${{ github.ref_type }}" = "tag" ]; then
54-
# Remove 'v' prefix if present (e.g., v1.0.0 -> 1.0.0)
55-
VERSION="${{ github.ref_name }}"
56-
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
5768
else
58-
# For branch pushes (like main), use base version with -ea.COMMIT_SHA suffix
59-
BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//')
60-
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
61-
SHORT_SHA=$(git rev-parse --short "${{ github.sha }}")
62-
VERSION="${BASE_VERSION}-ea.${SHORT_SHA}"
63-
else
64-
VERSION="$BASE_VERSION"
65-
fi
69+
echo "Not building image for this branch"
70+
exit 0
6671
fi
72+
6773
echo "version=$VERSION" >> $GITHUB_OUTPUT
68-
echo "Package version: $VERSION"
74+
echo "ea_build=$EA_BUILD" >> $GITHUB_OUTPUT
6975
7076
- name: Get image metadata
7177
id: image-meta
@@ -83,14 +89,14 @@ jobs:
8389
username: ${{ github.actor }}
8490
password: ${{ secrets.GITHUB_TOKEN }}
8591

86-
- name: Extract metadata (tags, labels) for Docker
92+
- name: Extract Docker metadata
8793
id: meta
8894
uses: docker/metadata-action@v5
8995
with:
9096
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
9197
tags: |
92-
type=raw,value=latest,enable={{is_default_branch}}
93-
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 }}
94100
95101
- name: Build and push Docker image
96102
uses: docker/build-push-action@v5

0 commit comments

Comments
 (0)