Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,22 @@ jobs:
assert.ok(changelogContent.includes('v0.1.0 (2025-11-20)'), 'Expected changelog to contain version 0.1.0');
assert.ok(changelogContent.includes('### Feat'), 'Expected changelog to contain a header for features');
assert.ok(changelogContent.includes('### Fix'), 'Expected changelog to contain a header for fixes');
test-trigger-other-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: ./
- id: get-version
run: |
current_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version
echo "current_version=$current_version" >> $GITHUB_OUTPUT
- name: trigger other workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow list
gh workflow run .github/workflows/trigger-me.yaml \
--ref "${{ github.head_ref }}" \
-f "version=${{ steps.get-version.outputs.current_version }}"
16 changes: 16 additions & 0 deletions .github/workflows/trigger-me.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
workflow_dispatch:
inputs:
version:
description: "Version to trigger"
required: true

jobs:
triggered-echo:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Trigger other job
run: |
echo "Version: ${{ inputs.version }}"
34 changes: 34 additions & 0 deletions examples/trigger-other-job/.github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Trigger other job

In this example, we trigger another job without having to configure a PAT token.
This is achieved by using github API and workflow_dispatch event.

```mermaid
flowchart LR
subgraph BR["bump-release"]
direction TB
bump
git_push["git push"]
create_changelog["create changelog"]
release
workflow_dispatch

bump --> git_push
git_push --> create_changelog
create_changelog --> release
release --> workflow_dispatch
end

subgraph TM["trigger-me"]
echo_version["echo version"]

%% Workaround to increase height of the graph
echo_version ~~~ spacer1[" "]:::hidden
spacer1 ~~~ spacer2[" "]:::hidden
spacer2 ~~~ spacer3[" "]:::hidden
spacer3 ~~~ spacer4[" "]:::hidden
spacer4 ~~~ spacer5[" "]:::hidden
end

BR --> TM
```
48 changes: 48 additions & 0 deletions examples/trigger-other-job/.github/workflows/bump-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# YES, YOU CAN COPY-PASTE THIS ACTION AND IT SHOULD WORK
# keep in mind, that it won't trigger other actions because it's using action permissions.
# You can: use a PAT token or a workflow_call to trigger another action
on:
push:
branches:
- main

jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: commitizen-tools/setup-cz@main
- id: bump-version
run: |
cz bump --yes --annotated-tag
git push --follow-tags
current_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version
echo "current_version=$current_version" >> $GITHUB_OUTPUT
- name: Build changelog for Release
env:
CURRENT_VERSION: ${{ steps.bump-version.outputs.current_version }}
run: |
cz changelog --dry-run "${CURRENT_VERSION}" > .changelog.md
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: ".changelog.md"
tag_name: ${{ steps.bump-version.outputs.current_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: trigger other workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run .github/workflows/trigger-me.yaml \
-f "version=${{ steps.bump-version.outputs.current_version }}"
14 changes: 14 additions & 0 deletions examples/trigger-other-job/.github/workflows/trigger-me.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
workflow_dispatch:
inputs:
version:
description: "Version to trigger"
required: true

jobs:
triggered-echo:
runs-on: ubuntu-latest
steps:
- name: Trigger other job
run: |
echo "Version: ${{ inputs.version }}"
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
python3
nodejs
commitizen
gh
];

shellHook = ''
Expand Down
Loading