Skip to content
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Trigger Jira Issue Creation

on:
pull_request:
types:
- closed

jobs:
prepare:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this job could be removed and set the inputs directly in the jira-issue job

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work since the create-jira-issue job requires environment variables and it's not possible to set any environment when the job implements a reusable workflow https://stackoverflow.com/questions/75386901/environments-in-github-actions-incompatible-with-reusable-workflows?utm_source=chatgpt.com

runs-on: ubuntu-latest
environment:
name: ${{ github.event.pull_request.base.ref }}
outputs:
story_summary: ${{ vars.MIGRATION_BACKLOG_JIRA_STORY_SUMMARY }}
story_description: ${{ vars.MIGRATION_BACKLOG_JIRA_STORY_DESCRIPTION }}
steps:
- run: echo "Preparing input vars..."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesnt print anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that prints Preparing input vars...
image

create-jira-issue:
needs: prepare
if: github.event.pull_request.merged == true
uses: nelc/actions-hub/.github/workflows/create-jira-issue.yml@main
with:
story_summary: ${{ needs.prepare.outputs.story_summary }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
story_summary: ${{ needs.prepare.outputs.story_summary }}
story_summary: ${{ vars.MIGRATION_BACKLOG_JIRA_STORY_SUMMARY }}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with repo variables, it's no possible to use environment variables

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think env.MIGRATION_BACKLOG_JIRA_STORY_SUMMARY doesnt work and vars yes. Or vars are not repo vars?. I mean here you could testing set env ${{ github.event.pull_request.base.ref }}.

https://docs.github.com/en/actions/reference/contexts-reference#contexts

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

story_description: ${{ needs.prepare.outputs.story_description }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
story_description: ${{ needs.prepare.outputs.story_description }}
story_description: ${{ vars.MIGRATION_BACKLOG_JIRA_STORY_DESCRIPTION }}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with repo variables, it's no possible to use environment variables

subtask_summary: "${{ github.event.pull_request.title }}"
subtask_description: "${{ github.event.pull_request.body }} 🔗 PR: ${{ github.event.pull_request.html_url }}"
environment: ${{ github.event.pull_request.base.ref }}
secrets:
MIGRATION_BACKLOG_JIRA_EMAIL: ${{ secrets.MIGRATION_BACKLOG_JIRA_EMAIL }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, how are these secrets being resolved if they are environment secrets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why vars don’t work in with:

GitHub evaluates that expression at the caller workflow level, before the reusable workflow starts.

At that point:

  • The environment has not been set yet.
  • So environment-scoped vars are not available.
  • As a result, the value is undefined or empty.

secrets are always available and injected early by GitHub — even at the top level.

MIGRATION_BACKLOG_JIRA_TOKEN: ${{ secrets.MIGRATION_BACKLOG_JIRA_TOKEN }}
MIGRATION_BACKLOG_JIRA_URL: ${{ secrets.MIGRATION_BACKLOG_JIRA_URL }}
MIGRATION_BACKLOG_JIRA_PROJECT: ${{ secrets.MIGRATION_BACKLOG_JIRA_PROJECT }}
MIGRATION_BACKLOG_JIRA_EPIC_KEY: ${{ secrets.MIGRATION_BACKLOG_JIRA_EPIC_KEY }}
MIGRATION_BACKLOG_JIRA_EPIC_LINK_FIELD: ${{ secrets.MIGRATION_BACKLOG_JIRA_EPIC_LINK_FIELD }}