Skip to content

Commit ad3f3c5

Browse files
committed
Provide default empty CLA file for read-file action
1 parent 7d183f9 commit ad3f3c5

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

check-cla/action.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ def main() -> None:
2323
args = parse_args()
2424

2525
path = args.cla_path
26-
signees = json.loads(path.read_text())
27-
signees["contributors"].append(args.contributor)
28-
signees["contributors"].sort(key=str.lower)
26+
try:
27+
signees = json.loads(path.read_text())
28+
except FileNotFoundError:
29+
signees = []
30+
signees.append(args.contributor)
31+
signees.sort(key=str.lower)
2932
path.write_text(json.dumps(signees, indent=2) + "\n")
3033

3134

check-cla/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ runs:
5757
with:
5858
path: https://raw.githubusercontent.com/${{ inputs.cla_repo }}/main/${{ inputs.cla_path }}
5959
parser: json
60+
default: '[]'
6061

6162
- name: Determine whether the contributor has signed the CLA
62-
run: echo HAS_SIGNED=${{ contains(fromJSON(steps.read_cla.outputs.content)['contributors'], env.CONTRIBUTOR) }} >> $GITHUB_ENV
63+
run: echo HAS_SIGNED=${{ contains(fromJSON(steps.read_cla.outputs.content), env.CONTRIBUTOR) }} >> $GITHUB_ENV
6364
shell: bash
6465

6566
# if contributor has already signed, add [cla-signed] label

0 commit comments

Comments
 (0)