Skip to content

Commit 003c563

Browse files
committed
fix: simplify workflow triggers
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 334513c commit 003c563

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
with:
2424
language: javascript
2525
repo-url: ${{ github.repository }}
26-
commit-sha: ${{ github.event.workflow_run && github.event.workflow_run.head_sha || github.sha }}
26+
commit-sha: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.workflow_run.head_sha && github.event.workflow_run.head_sha != github.event.workflow_run.base_sha && github.event.workflow_run.head_sha ||github.sha }}

.github/workflows/publish.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
name: Publish
44

55
on:
6-
workflow_run:
7-
workflows: ["Integration Tests"]
8-
types:
9-
- completed
6+
workflow_dispatch:
107
push:
8+
branches:
9+
- main
1110
tags:
1211
- 'v*.*.*'
1312

@@ -17,17 +16,14 @@ permissions:
1716

1817
jobs:
1918
publish-ea:
20-
if: |
21-
github.event_name == 'workflow_run' &&
22-
github.event.workflow_run.event == 'push' &&
23-
github.event.workflow_run.head_branch == 'main'
19+
if: startsWith(github.ref, 'refs/tags/') == false
2420
runs-on: ubuntu-latest
2521
name: Publish EA release to NPM
2622
steps:
2723
- name: Checkout sources
2824
uses: actions/checkout@v4
2925
with:
30-
ref: ${{ github.event.workflow_run.head_branch }}
26+
ref: ${{ github.ref_name }}
3127
fetch-depth: 0
3228

3329
- name: Install node 24
@@ -45,9 +41,9 @@ jobs:
4541
git config user.name "${{ github.actor }}"
4642
git config user.email "${{ github.actor }}@users.noreply.github.com"
4743
48-
- name: Reset to workflow run commit
44+
- name: Reset to commit
4945
run: |
50-
git reset --hard ${{ github.event.workflow_run.head_sha }}
46+
git reset --hard ${{ github.sha }}
5147
5248
- name: Get current version
5349
id: current-version
@@ -65,13 +61,13 @@ jobs:
6561

6662
- name: Publish package
6763
run: |
68-
SHORT_SHA=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}")
64+
SHORT_SHA=$(git rev-parse --short "${{ github.sha }}")
6965
EA_VERSION="${{ steps.current-version.outputs.base-version }}-ea.${SHORT_SHA}"
7066
npm version "$EA_VERSION" --no-git-tag-version
7167
npm publish --verbose --tag ea --access public --provenance
7268
7369
publish-release:
74-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
70+
if: startsWith(github.ref, 'refs/tags/')
7571
runs-on: ubuntu-latest
7672
name: Publish release to NPM
7773
steps:

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

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,19 @@
33
name: Push to registry
44

55
on:
6-
workflow_run:
7-
workflows: ["Integration Tests"]
8-
types:
9-
- completed
6+
workflow_dispatch:
107
push:
8+
branches:
9+
- main
1110
tags:
1211
- 'v*.*.*'
13-
workflow_dispatch:
1412

1513
env:
1614
REGISTRY: ghcr.io
1715
IMAGE_NAME: ${{ github.repository }}
1816

1917
jobs:
2018
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'
3419
runs-on: ubuntu-latest
3520
permissions:
3621
contents: read
@@ -55,7 +40,7 @@ jobs:
5540
- name: Determine package version
5641
id: version
5742
run: |
58-
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [[ "${GITHUB_REF}" =~ refs/tags/ ]]; then
43+
if [[ "${GITHUB_REF}" =~ refs/tags/ ]]; then
5944
# Release tag
6045
VERSION="${GITHUB_REF#refs/tags/v}"
6146
EA_BUILD=false
@@ -107,7 +92,7 @@ jobs:
10792
tags: ${{ steps.meta.outputs.tags }}
10893
labels: ${{ steps.meta.outputs.labels }}
10994
build-args: |
110-
IMAGE_VERSION=${{ steps.package-version.outputs.version }}
95+
IMAGE_VERSION=${{ steps.version.outputs.version }}
11196
IMAGE_REVISION=${{ steps.image-meta.outputs.revision }}
11297
IMAGE_CREATED=${{ steps.image-meta.outputs.created }}
11398
cache-from: type=gha

0 commit comments

Comments
 (0)