Reputation: 382
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 }}"
Upvotes: 38
Views: 14495
Reputation: 892
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 }}'
Upvotes: 1
Reputation: 1027
This can be achieved by using run-name
instead of name
for naming your action.
run-name: "Build and push ${{ github.event.inputs.tag }}"
Upvotes: 3
Reputation: 524
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/
Upvotes: 17
Reputation: 11943
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.
Upvotes: 3