Skip to content

Commit

Permalink
Finishing up v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RubbaBoy committed Mar 6, 2020
1 parent 2881dce commit f46a7d4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- id: date
run: echo "##[set-output name=data;]$(date)"
- name: Time badge
uses: RubbaBoy/BYOB@v1.0.0
uses: RubbaBoy/BYOB@v1.1.0
with:
NAME: time
LABEL: 'Updated at'
Expand Down Expand Up @@ -47,7 +47,7 @@ Only up to `branch` is required. The following are examples of more advanced bad

#### Basic off-master badge

Badges may be used off of the master branch. For example, on the `dev` branch:
Badges may be used off of the default orphan `shields` branch. For example, on the `dev` branch:

```markdown
![](https://runkit.io/rubbaboy/byob/branches/master/RubbaBoy/Example/time/dev)
Expand All @@ -58,10 +58,10 @@ Badges may be used off of the master branch. For example, on the `dev` branch:
Badges may also use custom JSON paths, allowing for multiple files per project for whatever your usecase may be. The branch must be included in this URL. The following shows a path to `/child/dir/badges.json`

```markdown
![](https://runkit.io/rubbaboy/byob/branches/master/RubbaBoy/Example/time/master/child/dir/badges.json)
![](https://runkit.io/rubbaboy/byob/branches/master/RubbaBoy/Example/time/shields/child/dir/badges.json)
```


An example of a repo with multiple badges may be found here: [BYOBTest](https://github.com/RubbaBoy/BYOBTest)

### Inputs

Expand All @@ -75,10 +75,11 @@ All inputs are required except for the last one displayed below.
| color | | The hex color of the badge. |
| github_token | | The GitHub token to push to the current repo. Suggested as `${{ secrets.GITHUB_TOKEN }}` |
| path | `/shields.json` | The absolute file path to store the JSON data to. |
| branch | `shields` | The branch to contain the shields file. |

## How It Works

BYOB is very simple, consisting of the GitHub Action and a small server-side script. The Action updates a branch-specific json file, containing data about all badges available (Any repo may use these). Each badge has a name associated with it only used for identification purposes, and is not displayed.
BYOB is very simple, consisting of the GitHub Action and a small server-side script. The Action updates a json file containing all badge info. This is by default the `shields` branch as to keep the commit history clean on working branches. Each badge has a name associated with it only used for identification purposes, and is not displayed.

When the Action is invoked, it will update only the badge names that have changed, to allow for more persistent data. Whenever a badge is invoked, a push is made to the repo updating the file. No badge data is stored server-side.

Expand Down
6 changes: 2 additions & 4 deletions bin/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:io';

Map<String, String> get env => Platform.environment;

Directory workingDir;

void main(List<String> args) {
Expand All @@ -16,7 +18,6 @@ void main(List<String> args) {
path = '/$path';
}

final env = Platform.environment;
final remote =
'https://${env['GITHUB_ACTOR']}:$token@github.com/${env['GITHUB_REPOSITORY']}.git';

Expand Down Expand Up @@ -60,13 +61,10 @@ void cloneRepo(String branch, String remote, String cloneInto) {
runCommand('git', ['checkout', '--orphan', branch]);
runCommand('git', ['rm', '-rf', '.']);
}

print('Done with repo stuff');
}

String runCommand(String cmd,
[List<String> args = const [], bool includeWorkingDir = true]) {
print('$cmd ${args.join(' ')}');
final process = includeWorkingDir
? Process.runSync(cmd, args, workingDirectory: workingDir.absolute.path)
: Process.runSync(cmd, args);
Expand Down
34 changes: 19 additions & 15 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f46a7d4

Please sign in to comment.