Skip to content

Commit

Permalink
Composite actions for badging (#196)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
prince-chrismc authored Jan 23, 2022
1 parent 5c9787e commit 8254f7c
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 121 deletions.
34 changes: 21 additions & 13 deletions .github/actions/badge/action.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
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
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
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 }}
24 changes: 0 additions & 24 deletions .github/actions/badge/failure/action.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/actions/badge/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions .github/actions/badge/success/action.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/actions/badge/write/action.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 7 additions & 17 deletions .github/workflows/cross-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,35 @@ jobs:
run: cp /usr/local/opt/[email protected]/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
./example/rsa-verify
- 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 }}
42 changes: 6 additions & 36 deletions .github/workflows/ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: libressl
label: ${{ matrix.libressl }}
github_token: ${{ secrets.GITHUB_TOKEN }}

wolfssl:
runs-on: ubuntu-latest
Expand All @@ -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
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
- if: github.event_name == 'push' && always()
uses: ./.github/actions/badge
with:
category: wolfssl
label: ${{ matrix.wolfssl.name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 7 additions & 7 deletions .github/workflows/traits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 8254f7c

Please sign in to comment.