Skip to content

Commit

Permalink
Provide default empty CLA file for read-file action
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Sep 9, 2024
1 parent 6937ecb commit e6ccfb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions check-cla/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ def main() -> None:
args = parse_args()

path = args.cla_path
signees = json.loads(path.read_text())
signees["contributors"].append(args.contributor)
signees["contributors"].sort(key=str.lower)
try:
signees = json.loads(path.read_text())
except FileNotFoundError:
signees = []
signees.append(args.contributor)
signees.sort(key=str.lower)
path.write_text(json.dumps(signees, indent=2) + "\n")


Expand Down
3 changes: 2 additions & 1 deletion check-cla/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ runs:
with:
path: https://raw.githubusercontent.com/${{ inputs.cla_repo }}/main/${{ inputs.cla_path }}
parse: json
default: '[]'

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

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

0 comments on commit e6ccfb7

Please sign in to comment.