Skip to content

Commit

Permalink
chore(docs,ci/build,action): switch to local action testing with cond…
Browse files Browse the repository at this point in the history
…itional execution, refine input handling
  • Loading branch information
ChipWolf committed Nov 18, 2023
1 parent a696ed4 commit 00777f3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Image
name: Build and Test

"on":
workflow_dispatch:
Expand All @@ -20,8 +20,8 @@ env:
IMAGE_NAME: chipwolf/badgesort

jobs:
build:
name: Build
image:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -45,13 +45,16 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
badgesort:
if: startsWith(github.ref, 'refs/tags/') || github.event_name != 'push'
name: Run BadgeSort
needs: [build]
needs: [image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: docker://ghcr.io/chipwolf/badgesort:latest
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 1
- name: Demo 1
uses: ./
with:
format: markdown
id: default
Expand All @@ -64,17 +67,20 @@ jobs:
opensea
sort: hilbert
style: for-the-badge
- uses: docker://ghcr.io/chipwolf/badgesort:latest
- name: Demo 2
uses: ./
with:
format: html
id: foobar
output: README.md
random: 5
sort: 'false'
sort: false
style: flat-square
- uses: docker://ghcr.io/chipwolf/badgesort:latest
- name: Demo 3
uses: ./
with:
opts: --hue-rotate 240
opts: |
--hue-rotate 240
id: example
format: html
output: README.md
Expand All @@ -86,7 +92,9 @@ jobs:
html5,insomnia,mongodb,nestjs,nodedotjs
npm,prettier,react,reactivex,redux
rollupdotjs,sass,styledcomponents,typescript,webpack
- uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # v9
- name: Commit and push
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # v9
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
with:
default_author: github_actions
message: 'chore(docs): refresh badgesort'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Release
name: Release Please

"on":
workflow_dispatch:
Expand All @@ -23,7 +23,7 @@ jobs:
release-please:
runs-on: ubuntu-22.04
steps:
- name: Please
- name: Release Please
uses: GoogleCloudPlatform/release-please-action@db8f2c60ee802b3748b512940dde88eabd7b7e01 # v3.7.13
with:
command: manifest
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ The badges can be sorted by color _[as default]_ or left in the order specified.
americanexpress
nodered
opensea
sort: 'hilbert' # default
style: 'for-the-badge' # default
sort: hilbert # default
style: for-the-badge # default
```
#### _CLI:_
```bash
$ python3 icons.py -s osu github americanexpress nodered opensea
$ python -m badgesort.icons -s osu github americanexpress nodered opensea
```

#### _Output:_
Expand All @@ -87,14 +87,14 @@ $ python3 icons.py -s osu github americanexpress nodered opensea
format: html
output: README.md
random: 5
sort: 'false'
sort: false
style: flat-square
```
#### _CLI:_
```bash
$ python3 icons.py -i foobar -s false -r 5 -f html -b flat-square
$ python -m badgesort.icons -i foobar -c false -r 5 -f html -b flat-square
```

#### _Output:_
Expand All @@ -119,11 +119,12 @@ $ python3 icons.py -i foobar -s false -r 5 -f html -b flat-square
```yaml
- uses: docker://ghcr.io/chipwolf/badgesort:latest
with:
args: '--hue-rotate 240'
args: |
--hue-rotate 240
id: example
format: html
output: README.md
sort: 'step_invert'
sort: step_invert
style: flat
slugs: |
angular,apollographql,brave,d3dotjs,docker
Expand All @@ -136,7 +137,7 @@ $ python3 icons.py -i foobar -s false -r 5 -f html -b flat-square
#### _CLI:_
```bash
$ python3 icons.py -i example -c step_invert -o README.md -f html -b flat-square --hue-rotate 240 -s \
$ python -m badgesort.icons -i example -c step_invert -o README.md -f html -b flat-square --hue-rotate 240 -s \
angular,apollographql,brave,d3dotjs,docker, \
git,githubactions,googlecloud,graphql,heroku, \
html5,insomnia,mongodb,nestjs,nodedotjs, \
Expand Down
43 changes: 20 additions & 23 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
name: 'BadgeSort'
description: 'Generate and sort branded Shields.io badges by color'
name: BadgeSort
description: Generate and sort branded Shields.io badges by color
branding:
icon: 'book-open'
color: 'green'
icon: book-open
color: green
inputs:
opts:
description: 'Additional options'
description: Additional options
required: false
default: ''
slugs:
description: 'SimpleIcons.org slugs to use.'
description: SimpleIcons.org slugs to use
required: false
default: ''
format:
description: 'Output format.'
description: Output format
required: false
default: 'markdown'
id:
description: 'Badge generation ID.'
description: Badge generation ID
required: false
default: 'default'
default: default
sort:
description: 'Color sorting algorithm'
description: Color sorting algorithm
required: false
default: 'hilbert'
default: hilbert
style:
description: 'Shields.io badge style.'
description: Shields.io badge style
required: false
default: 'for-the-badge'
default: for-the-badge
thanks:
description: 'Show the BadgeSort badge.'
description: Show the BadgeSort badge
required: false
default: true
type: boolean
random:
description: 'Number of random icons to generate.'
description: Number of random icons to generate
required: false
default: 1
default: 0
verify:
description: 'Verify the generated badge is valid by requesting it from Shields.io.'
description: Verify the generated badge is valid by requesting it from Shields.io
required: false
default: false
type: boolean
output:
description: 'Output file name'
description: Output file name
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
using: docker
image: Dockerfile
13 changes: 7 additions & 6 deletions badgesort/gh_actions_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@
for k, v in inputs.items():
if k == 'opts':
args_list.extend(v.split())
elif k == 'slugs':
elif v and k == 'slugs':
args_list.extend(['--slugs', ','.join(v.split())])
elif k == 'sort':
elif v and k == 'sort':
args_list.extend(['--color-sort', v])
elif k == 'style':
elif v and k == 'style':
args_list.extend(['--badge-style', v])
elif k == 'verify' or k == 'reverse':
elif v and k == 'verify' or k == 'reverse':
if v.lower() == 'true':
args_list.append(f'--{k}')
elif k == 'thanks':
elif v and k == 'thanks':
if v.lower() == 'false':
args_list.append('--no-thanks')
else:
args_list.extend([f'--{k}', v])
if v:
args_list.extend([f'--{k}', v])

logger.debug(args_list)

Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"release-as": "3.0.1",
"release-as": "3.1.0",
"release-type": "python",
"packages": {
".": {
Expand Down
1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2

0 comments on commit 00777f3

Please sign in to comment.