Composite actions for badging (#196)

* Improved badging actions

use new composite if feature to perform more heavy lifting (making the workflows more DRY)

* only make badges on push

* update ssl traits

* replace success/failure with generic write
This commit is contained in:
Chris Mc
2022-01-22 17:37:43 -08:00
committed by GitHub
parent 5c9787ebca
commit 8254f7cdfb
8 changed files with 68 additions and 121 deletions

View File

@@ -1,5 +1,5 @@
name: Make a Badge
description: Creates a JSON file for use with Sheilds.io. The default is a "brightgreen" "Passing" badge
name: Regular badging sequence
description: Publishes a badge based on the job status
inputs:
category:
description: The subfolder where to group the badges
@@ -7,18 +7,26 @@ inputs:
label:
description: The label to you in the badge (this should be unqie for each badge in a category)
required: true
message:
description: The message you wish to have in the badge
github_token:
description: The token to use to publish the changes
required: false
default: "Passing"
color:
description: The color you wish the badge to be
required: false
default: "brightgreen"
default: ${{ github.token }}
runs:
using: composite
steps:
- run: |
mkdir -p badges/${{ inputs.category }}/${{ inputs.label }}
echo '{ "schemaVersion": 1, "label": "${{ inputs.label }}", "message": "${{ inputs.message }}", "color": "${{ inputs.color }}" }' > badges/${{ inputs.category }}/${{ inputs.label }}/shields.json
shell: bash
- if: success()
uses: ./.github/actions/badge/write
with:
category: ${{ inputs.category }}
label: ${{ inputs.label }}
- if: |
!success()
uses: ./.github/actions/badge/write
with:
category: ${{ inputs.category }}
label: ${{ inputs.label }}
message: Failing
color: red
- uses: ./.github/actions/badge/publish
with:
github_token: ${{ inputs.github_token }}

View File

@@ -1,24 +0,0 @@
name: Make a Failure Badge
description: Publishes a badge indicating a 'Failing' status
inputs:
category:
description: The subfolder where to group the badges
required: true
label:
description: The label to you in the badge (this should be unqie for each badge in a category)
required: true
github_token:
description: The token to use to publish the changes
required: true
runs:
using: composite
steps:
- uses: ./.github/actions/badge
with:
category: ${{ inputs.category }}
label: ${{ inputs.label }}
message: Failing
color: red
- uses: ./.github/actions/badge/publish
with:
github_token: ${{ inputs.GITHUB_TOKEN }}

View File

@@ -3,13 +3,14 @@ description: Publishes all badges
inputs:
github_token:
description: The token to use to publish the changes
required: true
required: false
default: ${{ github.token }}
runs:
using: composite
steps:
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ inputs.GITHUB_TOKEN }}
github_token: ${{ inputs.github_token }}
publish_branch: badges
publish_dir: ./badges
keep_files: true

View File

@@ -1,22 +0,0 @@
name: Make a Success Badge
description: Publishes a badge indicating a successful 'Passing' status
inputs:
category:
description: The subfolder where to group the badges
required: true
label:
description: The label to you in the badge (this should be unqie for each badge in a category)
required: true
github_token:
description: The token to use to publish the changes
required: true
runs:
using: composite
steps:
- uses: ./.github/actions/badge
with:
category: ${{ inputs.category }}
label: ${{ inputs.label }}
- uses: ./.github/actions/badge/publish
with:
github_token: ${{ inputs.GITHUB_TOKEN }}

24
.github/actions/badge/write/action.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Make a Badge
description: Creates a JSON file for use with Sheilds.io. The default is a "brightgreen" "Passing" badge
inputs:
category:
description: The subfolder where to group the badges
required: true
label:
description: The label to you in the badge (this should be unqie for each badge in a category)
required: true
message:
description: The message you wish to have in the badge
required: false
default: "Passing"
color:
description: The color you wish the badge to be
required: false
default: "brightgreen"
runs:
using: composite
steps:
- run: |
mkdir -p badges/${{ inputs.category }}/${{ inputs.label }}
echo '{ "schemaVersion": 1, "label": "${{ inputs.label }}", "message": "${{ inputs.message }}", "color": "${{ inputs.color }}" }' > badges/${{ inputs.category }}/${{ inputs.label }}/shields.json
shell: bash

View File

@@ -20,21 +20,21 @@ jobs:
run: cp /usr/local/opt/openssl@1.1/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
- uses: actions/checkout@v2
- run: cmake -E make_directory ${{github.workspace}}/build
- run: cmake -E make_directory ${{ github.workspace }}/build
- name: configure
shell: bash # access regardless of the host operating system
working-directory: ${{github.workspace}}/build
working-directory: ${{ github.workspace }}/build
run: cmake $GITHUB_WORKSPACE -DJWT_BUILD_EXAMPLES=ON
- name: build
working-directory: ${{github.workspace}}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: cmake --build .
- if: matrix.os != 'windows-latest'
name: test
working-directory: ${{github.workspace}}/build
working-directory: ${{ github.workspace }}/build
shell: bash
run: |
./example/rsa-create
@@ -42,23 +42,13 @@ jobs:
- if: matrix.os == 'windows-latest'
name: test
working-directory: ${{github.workspace}}/build
working-directory: ${{ github.workspace }}/build
run: |
example\Debug\rsa-create.exe
example\Debug\rsa-verify.exe
- name: badge success
if: github.event_name == 'push' && success()
uses: ./.github/actions/badge/success
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: cross-platform
label: ${{ matrix.os }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: badge failure
if: github.event_name == 'push' && !success()
uses: ./.github/actions/badge/failure
with:
category: cross-platform
label: ${{ matrix.os }}
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -31,21 +31,11 @@ jobs:
- name: test
run: ./tests/jwt-cpp-test
- name: badge success
if: github.event_name == 'push' && success()
uses: ./.github/actions/badge/success
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: openssl
label: ${{ matrix.openssl.name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: badge failure
if: github.event_name == 'push' && !success()
uses: ./.github/actions/badge/failure
with:
category: openssl
label: ${{ matrix.openssl.name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
openssl-no-deprecated:
runs-on: ubuntu-latest
@@ -82,21 +72,11 @@ jobs:
- name: test
run: ./tests/jwt-cpp-test
- name: badge success
if: github.event_name == 'push' && success()
uses: ./.github/actions/badge/success
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: libressl
label: ${{ matrix.libressl }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: badge failure
if: github.event_name == 'push' && !success()
uses: ./.github/actions/badge/failure
with:
category: libressl
label: ${{ matrix.libressl }}
github_token: ${{ secrets.GITHUB_TOKEN }}
wolfssl:
runs-on: ubuntu-latest
@@ -119,18 +99,8 @@ jobs:
- name: test
run: ./tests/jwt-cpp-test
- name: badge success
if: github.event_name == 'push' && success()
uses: ./.github/actions/badge/success
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: wolfssl
label: ${{ matrix.wolfssl.name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: badge failure
if: github.event_name == 'push' && !success()
uses: ./.github/actions/badge/failure
with:
category: wolfssl
label: ${{ matrix.wolfssl.name }}
github_token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -61,21 +61,21 @@ jobs:
- name: badge success
if: github.event_name == 'push' && success()
uses: ./.github/actions/badge
uses: ./.github/actions/badge/write
with:
category: traits
label: ${{ matrix.target.name }}
message: ${{ matrix.target.version }}
color: lightblue # turquoise
- if: github.event_name == 'push' && success()
uses: ./.github/actions/badge/publish
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: badge failure
if: github.event_name == 'push' && !success()
uses: ./.github/actions/badge/failure
uses: ./.github/actions/badge/write
with:
category: traits
label: ${{ matrix.target.name }}
message: ${{ matrix.target.version }}
color: orange
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge/publish
with:
github_token: ${{ secrets.GITHUB_TOKEN }}