How to create a custom badge in Github actions

Viewed 321

I have a simple Resume generator repo. It has a pipeline that runs the script where a markdown resume will be converted to a pdf file.

It creates downloadable content as shown below

enter image description here

This workflow looks nice but every time I want to download the artifact I have to navigate to the actions tab check the latest job and then download the file.

I was wondering if there is an option to create a special badge for it, which can be referenced in the readme, and when I click it would trigger the latest artifact download.

Artifact download link looks like this

https://github.com/n1md7/resume/suites/5221025505/artifacts/160003915

I looked a bit and it turned out there is one option in the marketplace. Bring your own badge

I tried to use it and it works as it generates a custom badge. However, in my use case, I need to inject a download link which is dynamic.

Any ideas on how can I achieve that?

This is my current workflow

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - name: Install Dependencies
      run: npm ci
    - name: Generate PDF from MarkDown
      run: npm run generate
    - name: Archive generated file
      uses: actions/upload-artifact@v2
      with:
        name: RESUME-latest.pdf
        path: RESUME.pdf

  badge_job:
    runs-on: ubuntu-latest
    steps:
      - id: download
        # Change me
        run: echo "##[set-output name=data;]$(date)"
      - name: Download badge
        uses: RubbaBoy/BYOB@v1.2.1
        with:
          NAME: Download
          LABEL: 'Download resume'
          STATUS: ${{ steps.download.outputs.data }}
          COLOR: 00EEFF
          GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
          REPOSITORY: n1md7/resume
          ACTOR: n1md7

When the file is generated I'd like to pass that file path to badge_job (or combined) to be included somehow.

0 Answers
Related