Skip to content

Commit 311a18c

Browse files
tj098895TeeeJay
authored andcommitted
ci: trigger publish based on another workflow completion
because github actions doesnt allow us to listen to published events for a release from an automatically triggered workflow, we instead need to check if another workflow has run to completion, and if so, we will run publish. We therefore trigger a trigger-publish workflow, if a release has been created, that we listen to in the publish workflow, and will then trigger Refs: equinor/ecalc-internal#433
1 parent 8daa219 commit 311a18c

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
name: Publish libeCalc package to PyPI
22

33
on:
4-
release: # Trigger automatically, when a new release is made (with release-please)
5-
types: [published]
4+
workflow_run:
5+
workflows: [trigger-publish]
6+
types:
7+
- completed
8+
# Note! We cannot trigger on published event, since that can only be triggered when done manually.
9+
# Therefore we trigger this workflow independently, after the trigger-publish workflow has run, in
10+
# order for this workflow to be the owner of the PyPI publishing job, and can be verified. This limits
11+
# us to only allow this workflow to be allowed to publish to PyPI trustedly.
612

713
workflow_dispatch: # Trigger manually, if needed
814

.github/workflows/release-please.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ jobs:
1717
outputs:
1818
release_created: ${{ steps.release.outputs.release_created }}
1919
tag_name: ${{ steps.release.outputs.tag_name }}
20+
21+
deploy_prod:
22+
needs: release-please
23+
uses: equinor/ecalc/.github/workflows/trigger-publish.yml@main
24+
if: ${{ needs.release-please.outputs.release_created }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: trigger-publish
2+
3+
# NOTE! This workflow is needed in order to trigger the publish workflow, which is not possible from within a reusable workflow.
4+
# If this is triggered, we will publish, as this should only trigger when a release is created by the release-please workflow.
5+
6+
on:
7+
workflow_dispatch: # Workflow dispatch is used for manual triggers.
8+
workflow_call: # Workflow call is used for called from another workflow.
9+
10+
jobs:
11+
trigger-publish:
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- name: trigger-publish
15+
run: echo "Trigger publish workflow"

0 commit comments

Comments
 (0)