I have a Github action that sets a name and is run on pull requests:
name: Code Quality
on:
workflow_dispatch:
pull_request:
branches: [ main, develop ]
When I trigger the run manually (because workflow_dispatch is also set), the run will get the title “Code Quality” in the list of runs.
But when the action is run on a pull request, the run name in the list is set to the name of the PR. That may or may not be a good title, very much depending on the PR’s author. Is there a way to influence the title of the action in the list?
Since Sept. 2022, there might be a way to set the title of the run itself:
GitHub Actions: Dynamic names for workflow runs (Sep. 2022)
GitHub Actions customers can now dynamically name their workflow runs.
The new run-name feature will accept expressions and be displayed on the list of workflow runs.
For more information on how to use run-name, visit the documentation.
For questions, visit the GitHub Actions community.
To see what's next for Actions, visit our public roadmap.
You now have:
The name for workflow runs generated from the workflow.
GitHub displays the workflow run name in the list of workflow runs on your repository's "Actions" tab.
If you omit run-name, the run name is set to event-specific information for the workflow run.
For example, for a workflow triggered by a push or pull_request event, it is set as the commit message.
This value can include expressions and can reference the github and inputs contexts.
Example
run-name: Deploy to ${{ inputs.deploy_target }} by #${{ github.actor }}
It does not seem like there is a way to set the title of the run itself (reference).
Scheduled and manual runs will get the title of the workflow, and runs triggered by commit / PR will get the commit message or PR title.
However, notice that the commit / PR title is displayed in addition to the name of the workflow, which appears in two places:
Related
I'm quite a rookie with GitHub Actions so this might be a stupid question: Is there a way to link pull requests with issues (in the UI linked PRs are shown under Development) in Github Actions using Github CLI or octokit/rest.js via actions/github-script?
enter image description here
Background: there is a workflow that creates pull requests. That works fine, only thing missing is the link between issues and corresponding pull requests. I would prefer not to use keywords nor other custom actions from the marketplace.
I've searched in the octokit/rest.js documentation https://octokit.github.io/rest.js/v19 under Issues and Pulls as well as in the GitHub cli documentation https://cli.github.com/manual/gh but couldn't find a solution.
I would like to have a solution either using GitHub Script https://github.com/marketplace/actions/github-script
or the command line.
You can use the Add an issue link Action for that.
This Action allows linking issues to Pull Requests. For example:
name: 'Issue Links'
on:
pull_request:
types: [opened]
jobs:
issue-links:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: tkt-actions/add-issue-links#v1.8.1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}' # required
branch-prefix: 'issue-' # required
This workflow will trigger on Pull Request open and link related issues mentioned in the PR body.
Make sure to set the corresponding permission for the job:
permissions:
pull-requests: write
For more about these permissions visit the Permissions for the GITHUB_TOKEN.
We have a workflow that runs whenever a tag with a specific format is pushed to the main repository. Originally, the displayed name is consistent with the name: entry at the beginning of the workflow file, but this is no longer the case.
Before this change, we had a separate repository with a cron workflow that ran a python script to push the tag to the main repository, which triggers the workflow there.
We recently moved to using a workflow from the main repository to push the tag, and this is when the different workflow display name changed. There are some differences between the two triggering workflows. The old trigger ran a python script which presumably pushed the tags "from" the script. The new trigger explicitly calls git push --tags from the workflow file itself.
I believe the move to the new trigger is why the display name is changed, but I cannot be certain.
I have created on my main branch with
on:
push:
branches: [ test ]
I have noticed, that while I can trigger it manually, and it will work, it will not actually trigger if I push to test. For that, I needed to create that same action file on test. Now, it seems like I don't even need to have the action on the main branch, is that correct?
So why does even the option so specify the branch that it should trigger on exist? It only triggers on the branches the file exists anyway. That said, I found it frustrating that I have to merge my one file from main to my test branch, is there a way to trigger the action automatically on push even if I do not have it on my test branch, only on main?
No, it's not possible. The order of operations in a workflow run triggered by push or pull request is described in the reference documentation:
An event occurs on your repository. The event has an associated commit SHA and Git ref.
GitHub searches the .github/workflows directory in your repository for workflow files that are present in the associated commit SHA or Git ref of the event.
A workflow run is triggered for any workflows that have on: values that match the triggering event. Some events also require the workflow file to be present on the default branch of the repository in order to run.
I have a manually triggered job that builds and deploys an image based on the tag I specify. Is there a way to make the workflow name dynamic?
name: Build and push
on:
workflow_dispatch:
inputs:
tag:
description: 'Image Tag'
required: true
jobs:
...
I would like to do something like
name: "Build and push ${{ github.event.inputs.tag }}"
As of Sep 26th 2022, this is now supported. Here's the announcement (which contains a link to the documentataion): https://github.blog/changelog/2022-09-26-github-actions-dynamic-names-for-workflow-runs/
Workflow names are not dynamic, but fixed.
To get at the actual data of a workflow run, you'll have to chose the specific run from the Actions > All Workflows > [name-of-your-workflow] list.
Alternatively, you can think about other ways to propagate the outcomes of your builds.
Our team, for example, propagates build outcomes to teams chat channel (in our case Microsoft Teams using the action notify-microsoft-teams). If you search the market place you'll find plenty of actions for this.
Another alternative could be to generated custom badges, which you could then make visible to your team. A nice action for this is bring-your-own-badge.
Last but not least you can propagate your workflow run data using emails (again, there are actions which do this for you).
The Actions tab shows workflows created in main branche's /.github/workflows/ only
I have workflow.yml files with workflow_dispatch trigger that are defined in another branch (test) that are not yet merged into the main branch
Is there any way I can see and run workflows with workflow_dispatch trigger that are created in another branch not yet merged with the main branch?
It looks that you can't change at the moment. It takes actions from default branch. You can change default branch but I assume that this is not acceptable for you (which I understand). Please take a look here on github community -
Workflow files only picked up from master?
If you use a web browser, you will see a dropdown - Use workflow from
If you use GitHub CLI, you need to use --ref flag
gh.exe workflow run workflown_name --ref branch_name -f param_name=value
documentation is here