OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

GitHub Actions 'workflow_run' event how to edit UI workflow name dynamically?

  • Thread starter Thread starter Alberto Piñón Formoso
  • Start date Start date
A

Alberto Piñón Formoso

Guest
I have three workflows on Github Actions ci.yml, release.yml and cd.yml when release.yml ends its execution, automatically cd.yml starts with a workflow_run, but the message that appears on the Github UI is the name of the workflow. I want to know if there's a way to dynamically set display name on the Github UI based on maybe a commit or a branch.

I pushed a tag v0.0.3 with the commit message of "initial layout" and when that workflow ends, the cd workflow starts, but on the UI appears as "cd" I want to change dynamically the title of that workflow from the yaml file so it appears like "v0.0.3" instead of "cd", is there a way to do this? enter image description here

ci.yml

Code:
name: ci

on:
  push:
    branches: [ master, dev, 'feature/**', 'bugfix/**', 'hotfix/**' ]
  pull_request:
    branches: [ master, dev ]
  workflow_call:

jobs:
  lint:
    strategy:
      matrix:
        go-version: [ 1.18.x ]
        platform: [ ubuntu-latest ]
    name: lint files
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
      - name: golangci-lint
        uses: golangci/[email protected]
        with:
          version: latest

  test:
    needs: [ lint ]
    strategy:
      matrix:
        go-version: [ 1.18.x ]
        platform: [ ubuntu-latest ]
    name: test go app
    runs-on: ${{ matrix.platform }}
    steps:
      - name: setup go
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
      - uses: actions/checkout@v3
      - name: test go app
        run: go test -v ./...

  build:
    needs: [ lint ]
    strategy:
      matrix:
        go-version: [ 1.18.x ]
        platform: [ ubuntu-latest ]
    name: build go app
    runs-on: ${{ matrix.platform }}
    steps:
    - name: setup go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go-version }}
    - name: checkout repository
      uses: actions/checkout@v3
    - name: build artifacts
      run: |
        go build -o bin/app ./cmd/...

release.yml

Code:
name: ci release

on:
  push:
    tags:
      - 'v*'

jobs:
  ci:
    uses: ./.github/workflows/ci.yml

  release:
    name: release / create github release
    needs: [ci]
    runs-on: ubuntu-latest
    if: success() && startsWith(github.ref_name, 'v') && github.ref_type == 'tag' && github.event_name == 'push'
    outputs:
      RELEASE_URL: ${{ steps.create_release.outputs.upload_url }}
    steps:
      - uses: actions/checkout@master
      - name: create release
        uses: actions/create-release@master
        id: create_release
        with:
          draft: false
          prerelease: true
          release_name: ${{ github.ref_name }}
          tag_name: ${{ github.ref_name }}
          body_path: CHANGELOG.md
        env:
          GITHUB_TOKEN: ${{ github.token }}  # ${{ secrets.PAT_TOKEN }}

  build_artifact:
    needs: [ release ]
    strategy:
      matrix:
        go-version: [ 1.18.x ]
        platform: [ ubuntu-latest ]
    name: build artifact
    runs-on: ${{ matrix.platform }}
    steps:
    - name: setup go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go-version }}
    - name: checkout repository
      uses: actions/checkout@v3
    - name: build artifacts
      run: |
        go build -o bin/app ./cmd/...
        zip bin.zip ./bin/app
    - name: upload linux artifact
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ github.token }}
      with:
        upload_url: ${{ needs.release.outputs.RELEASE_URL }}
        asset_path: ./bin.zip
        asset_name: app
        asset_content_type: application/zip

cd.yml

Code:
name: cd

on:
  workflow_run:
    workflows: [ "ci release" ]
    types:
      - completed
    branch: [ master ]

jobs:
  deploy:
    name: "deploy to heroku"
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.workflow_run.head_branch }} 
      - name: Terraform validate
        run: terraform validate
      - name: Terraform init - apply
        run: |
          cd terraform
          export HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} HEROKU_EMAIL=${{ secrets.HEROKU_EMAIL }}
          terraform init -backend-config="conn_str=${{ secrets.TERRAFORM_BE }}"
          terraform apply -var build_version=${{ github.event.workflow_run.head_branch }} --auto-approve
<p>I have three workflows on Github Actions <code>ci.yml</code>, <code>release.yml</code> and <code>cd.yml</code> when <code>release.yml</code> ends its execution, automatically <code>cd.yml</code> starts with a workflow_run, but the message that appears on the Github UI is the name of the workflow. I want to know if there's a way to dynamically set display name on the Github UI based on maybe a commit or a branch.</p>
<p>I pushed a tag <code>v0.0.3</code> with the commit message of "initial layout" and when that workflow ends, the cd workflow starts, but on the UI appears as "cd" I want to change dynamically the title of that workflow from the yaml file so it appears like "v0.0.3" instead of "cd", is there a way to do this?
<a href="https://i.sstatic.net/APhdY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/APhdY.png" alt="enter image description here" /></a></p>
<p>ci.yml</p>
<pre class="lang-yaml prettyprint-override"><code>name: ci

on:
push:
branches: [ master, dev, 'feature/**', 'bugfix/**', 'hotfix/**' ]
pull_request:
branches: [ master, dev ]
workflow_call:

jobs:
lint:
strategy:
matrix:
go-version: [ 1.18.x ]
platform: [ ubuntu-latest ]
name: lint files
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: golangci-lint
uses: golangci/[email protected]
with:
version: latest

test:
needs: [ lint ]
strategy:
matrix:
go-version: [ 1.18.x ]
platform: [ ubuntu-latest ]
name: test go app
runs-on: ${{ matrix.platform }}
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: test go app
run: go test -v ./...

build:
needs: [ lint ]
strategy:
matrix:
go-version: [ 1.18.x ]
platform: [ ubuntu-latest ]
name: build go app
runs-on: ${{ matrix.platform }}
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: checkout repository
uses: actions/checkout@v3
- name: build artifacts
run: |
go build -o bin/app ./cmd/...
</code></pre>
<p>release.yml</p>
<pre class="lang-yaml prettyprint-override"><code>name: ci release

on:
push:
tags:
- 'v*'

jobs:
ci:
uses: ./.github/workflows/ci.yml

release:
name: release / create github release
needs: [ci]
runs-on: ubuntu-latest
if: success() && startsWith(github.ref_name, 'v') && github.ref_type == 'tag' && github.event_name == 'push'
outputs:
RELEASE_URL: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@master
- name: create release
uses: actions/create-release@master
id: create_release
with:
draft: false
prerelease: true
release_name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }} # ${{ secrets.PAT_TOKEN }}

build_artifact:
needs: [ release ]
strategy:
matrix:
go-version: [ 1.18.x ]
platform: [ ubuntu-latest ]
name: build artifact
runs-on: ${{ matrix.platform }}
steps:
- name: setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: checkout repository
uses: actions/checkout@v3
- name: build artifacts
run: |
go build -o bin/app ./cmd/...
zip bin.zip ./bin/app
- name: upload linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.release.outputs.RELEASE_URL }}
asset_path: ./bin.zip
asset_name: app
asset_content_type: application/zip
</code></pre>
<p>cd.yml</p>
<pre class="lang-yaml prettyprint-override"><code>name: cd

on:
workflow_run:
workflows: [ "ci release" ]
types:
- completed
branch: [ master ]

jobs:
deploy:
name: "deploy to heroku"
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Terraform validate
run: terraform validate
- name: Terraform init - apply
run: |
cd terraform
export HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} HEROKU_EMAIL=${{ secrets.HEROKU_EMAIL }}
terraform init -backend-config="conn_str=${{ secrets.TERRAFORM_BE }}"
terraform apply -var build_version=${{ github.event.workflow_run.head_branch }} --auto-approve
</code></pre>
Continue reading...
 

Latest posts

Online statistics

Members online
1
Guests online
2
Total visitors
3
Top