Skip to content

Commit 8254f7c

Browse files
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
1 parent 5c9787e commit 8254f7c

File tree

8 files changed

+68
-121
lines changed

8 files changed

+68
-121
lines changed

.github/actions/badge/action.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
name: Make a Badge
2-
description: Creates a JSON file for use with Sheilds.io. The default is a "brightgreen" "Passing" badge
1+
name: Regular badging sequence
2+
description: Publishes a badge based on the job status
33
inputs:
44
category:
55
description: The subfolder where to group the badges
66
required: true
77
label:
88
description: The label to you in the badge (this should be unqie for each badge in a category)
99
required: true
10-
message:
11-
description: The message you wish to have in the badge
10+
github_token:
11+
description: The token to use to publish the changes
1212
required: false
13-
default: "Passing"
14-
color:
15-
description: The color you wish the badge to be
16-
required: false
17-
default: "brightgreen"
13+
default: ${{ github.token }}
1814
runs:
1915
using: composite
2016
steps:
21-
- run: |
22-
mkdir -p badges/${{ inputs.category }}/${{ inputs.label }}
23-
echo '{ "schemaVersion": 1, "label": "${{ inputs.label }}", "message": "${{ inputs.message }}", "color": "${{ inputs.color }}" }' > badges/${{ inputs.category }}/${{ inputs.label }}/shields.json
24-
shell: bash
17+
- if: success()
18+
uses: ./.github/actions/badge/write
19+
with:
20+
category: ${{ inputs.category }}
21+
label: ${{ inputs.label }}
22+
- if: |
23+
!success()
24+
uses: ./.github/actions/badge/write
25+
with:
26+
category: ${{ inputs.category }}
27+
label: ${{ inputs.label }}
28+
message: Failing
29+
color: red
30+
- uses: ./.github/actions/badge/publish
31+
with:
32+
github_token: ${{ inputs.github_token }}

.github/actions/badge/failure/action.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/actions/badge/publish/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ description: Publishes all badges
33
inputs:
44
github_token:
55
description: The token to use to publish the changes
6-
required: true
6+
required: false
7+
default: ${{ github.token }}
78
runs:
89
using: composite
910
steps:
1011
- uses: peaceiris/actions-gh-pages@v3
1112
with:
12-
github_token: ${{ inputs.GITHUB_TOKEN }}
13+
github_token: ${{ inputs.github_token }}
1314
publish_branch: badges
1415
publish_dir: ./badges
1516
keep_files: true

.github/actions/badge/success/action.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Make a Badge
2+
description: Creates a JSON file for use with Sheilds.io. The default is a "brightgreen" "Passing" badge
3+
inputs:
4+
category:
5+
description: The subfolder where to group the badges
6+
required: true
7+
label:
8+
description: The label to you in the badge (this should be unqie for each badge in a category)
9+
required: true
10+
message:
11+
description: The message you wish to have in the badge
12+
required: false
13+
default: "Passing"
14+
color:
15+
description: The color you wish the badge to be
16+
required: false
17+
default: "brightgreen"
18+
runs:
19+
using: composite
20+
steps:
21+
- run: |
22+
mkdir -p badges/${{ inputs.category }}/${{ inputs.label }}
23+
echo '{ "schemaVersion": 1, "label": "${{ inputs.label }}", "message": "${{ inputs.message }}", "color": "${{ inputs.color }}" }' > badges/${{ inputs.category }}/${{ inputs.label }}/shields.json
24+
shell: bash

.github/workflows/cross-platform.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,35 @@ jobs:
2020
run: cp /usr/local/opt/openssl@1.1/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
2121

2222
- uses: actions/checkout@v2
23-
- run: cmake -E make_directory ${{github.workspace}}/build
23+
- run: cmake -E make_directory ${{ github.workspace }}/build
2424

2525
- name: configure
2626
shell: bash # access regardless of the host operating system
27-
working-directory: ${{github.workspace}}/build
27+
working-directory: ${{ github.workspace }}/build
2828
run: cmake $GITHUB_WORKSPACE -DJWT_BUILD_EXAMPLES=ON
2929

3030
- name: build
31-
working-directory: ${{github.workspace}}/build
31+
working-directory: ${{ github.workspace }}/build
3232
shell: bash
3333
run: cmake --build .
3434

3535
- if: matrix.os != 'windows-latest'
3636
name: test
37-
working-directory: ${{github.workspace}}/build
37+
working-directory: ${{ github.workspace }}/build
3838
shell: bash
3939
run: |
4040
./example/rsa-create
4141
./example/rsa-verify
4242
4343
- if: matrix.os == 'windows-latest'
4444
name: test
45-
working-directory: ${{github.workspace}}/build
45+
working-directory: ${{ github.workspace }}/build
4646
run: |
4747
example\Debug\rsa-create.exe
4848
example\Debug\rsa-verify.exe
4949
50-
- name: badge success
51-
if: github.event_name == 'push' && success()
52-
uses: ./.github/actions/badge/success
50+
- if: github.event_name == 'push' && always()
51+
uses: ./.github/actions/badge
5352
with:
5453
category: cross-platform
5554
label: ${{ matrix.os }}
56-
github_token: ${{ secrets.GITHUB_TOKEN }}
57-
58-
- name: badge failure
59-
if: github.event_name == 'push' && !success()
60-
uses: ./.github/actions/badge/failure
61-
with:
62-
category: cross-platform
63-
label: ${{ matrix.os }}
64-
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ssl.yml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,11 @@ jobs:
3131
- name: test
3232
run: ./tests/jwt-cpp-test
3333

34-
- name: badge success
35-
if: github.event_name == 'push' && success()
36-
uses: ./.github/actions/badge/success
34+
- if: github.event_name == 'push' && always()
35+
uses: ./.github/actions/badge
3736
with:
3837
category: openssl
3938
label: ${{ matrix.openssl.name }}
40-
github_token: ${{ secrets.GITHUB_TOKEN }}
41-
42-
- name: badge failure
43-
if: github.event_name == 'push' && !success()
44-
uses: ./.github/actions/badge/failure
45-
with:
46-
category: openssl
47-
label: ${{ matrix.openssl.name }}
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
4939

5040
openssl-no-deprecated:
5141
runs-on: ubuntu-latest
@@ -82,21 +72,11 @@ jobs:
8272
- name: test
8373
run: ./tests/jwt-cpp-test
8474

85-
- name: badge success
86-
if: github.event_name == 'push' && success()
87-
uses: ./.github/actions/badge/success
88-
with:
89-
category: libressl
90-
label: ${{ matrix.libressl }}
91-
github_token: ${{ secrets.GITHUB_TOKEN }}
92-
93-
- name: badge failure
94-
if: github.event_name == 'push' && !success()
95-
uses: ./.github/actions/badge/failure
75+
- if: github.event_name == 'push' && always()
76+
uses: ./.github/actions/badge
9677
with:
9778
category: libressl
9879
label: ${{ matrix.libressl }}
99-
github_token: ${{ secrets.GITHUB_TOKEN }}
10080

10181
wolfssl:
10282
runs-on: ubuntu-latest
@@ -119,18 +99,8 @@ jobs:
11999
- name: test
120100
run: ./tests/jwt-cpp-test
121101

122-
- name: badge success
123-
if: github.event_name == 'push' && success()
124-
uses: ./.github/actions/badge/success
125-
with:
126-
category: wolfssl
127-
label: ${{ matrix.wolfssl.name }}
128-
github_token: ${{ secrets.GITHUB_TOKEN }}
129-
130-
- name: badge failure
131-
if: github.event_name == 'push' && !success()
132-
uses: ./.github/actions/badge/failure
102+
- if: github.event_name == 'push' && always()
103+
uses: ./.github/actions/badge
133104
with:
134105
category: wolfssl
135106
label: ${{ matrix.wolfssl.name }}
136-
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/traits.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ jobs:
6161
6262
- name: badge success
6363
if: github.event_name == 'push' && success()
64-
uses: ./.github/actions/badge
64+
uses: ./.github/actions/badge/write
6565
with:
6666
category: traits
6767
label: ${{ matrix.target.name }}
6868
message: ${{ matrix.target.version }}
6969
color: lightblue # turquoise
70-
- if: github.event_name == 'push' && success()
71-
uses: ./.github/actions/badge/publish
72-
with:
73-
github_token: ${{ secrets.GITHUB_TOKEN }}
74-
7570
- name: badge failure
7671
if: github.event_name == 'push' && !success()
77-
uses: ./.github/actions/badge/failure
72+
uses: ./.github/actions/badge/write
7873
with:
7974
category: traits
8075
label: ${{ matrix.target.name }}
76+
message: ${{ matrix.target.version }}
77+
color: orange
78+
- if: github.event_name == 'push' && always()
79+
uses: ./.github/actions/badge/publish
80+
with:
8181
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)