39

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 }}"
2
  • 1
    What is the purpose? Commented Jan 8, 2021 at 18:19
  • 1
    we have a team of ~4 that uses actions on this repo, it would be great to have a glance of who built which image when on the /actions page. For example if someone on my team built 0.1.1, I would have to either ping a group chat or click on the latest workflow to find out the latest image tag. Commented Jan 11, 2021 at 15:24

4 Answers 4

20

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/

Sign up to request clarification or add additional context in comments.

3 Comments

This is only for public Github. How about Enterprise?
Enterprise works too
It may save readers some time to know that run-name is very limited – you can only use gh expressions, and cannot update the workflow name based on the outputs of jobs or steps.
4

This can be achieved by using run-name instead of name for naming your action.

run-name: "Build and push ${{ github.event.inputs.tag }}"

Comments

3

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).

2 Comments

Thanks, I found a (in my case) Slack hook to be the best workaround. Creating releases/tags from each build was also a decent but noisy approach.
We also hook into slack and show who caused the action to fire and what server and other tags. It is helpful, but I would like to see this info on the "All Workflows" screen in github. That would be more useful than the same name for every run. Our build can build a number of different systems, all handled by the same action.
1

I wanted to share this workflow if anyone is looking to have a dynamic environment name in the run-name.

I can confirm that this is working for me. Although the doc says that the run-name has only access to {{ inputs }} and {{ github }} contexts, but when I added a variable at the repository level (under Github secrets) and accessed it using the vars.DEFAULT_ENVIRONMENT surprisingly it worked. You may use the same trick to achieve what you are looking for.

May be this is an undocumented feature ( bit reluctant to post if they remove it after its discovery 😁 ).

on:
  push:
    branches:
      - main
    paths:
      - 'abcd/**'
  workflow_dispatch:
    inputs:
      environment:
        description: 'Choose the deployment environment'
        required: false
        default: 'DEV'
        type: choice
        options:
          - DEV
          - UAT
          - PROD

run-name: '${{ github.event.inputs.environment || vars.DEFAULT_ENVIRONMENT }} - Run ID: ${{ github.run_id }} - by @${{ github.actor }}'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.