diff --git a/action.yml b/action.yml new file mode 100644 index 00000000..ca44f420 --- /dev/null +++ b/action.yml @@ -0,0 +1,63 @@ +name: 'scitt-client' +description: 'Create and submit statement to a SCITT instance' +inputs: + issuer: + description: 'Issuer of statement' + required: true + subject: + description: 'Subject of statement' + required: true + payload: + description: 'Payload for statement' + required: true + payload-content-type: + description: 'Statement payload content-type' + required: false + default: 'application/json' + private-key-pem: + description: 'Private key pem bytes' + required: true + scitt-url: + description: 'URL of scitt instance' + required: true + scitt-pip-install: + description: 'Argument to pass to pip to install scitt-emulator Python package (defaults to main.tar.gz of upstream repo)' + default: 'https://github.com/scitt-community/scitt-api-emulator/archive/refs/heads/main.tar.gz' +outputs: + entry-id: + description: "Entry ID of submitted statement" + value: ${{ steps.submit-statement.outputs.entry-id }} +runs: + using: "composite" + steps: + - uses: actions/setup-python@v5 + id: setup-python + with: + python-version: '3.12' + update-environment: false + - name: "Install Dependencies" + shell: bash -xeuo pipefail {0} + env: + SCITT_PIP_INSTALL: ${{ inputs.scitt-pip-install }} + run: | + export LD_LIBRARY_PATH="$(dirname $(dirname ${{ steps.setup-python.outputs.python-path }}))/lib:${LD_LIBRARY_PATH}" + echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV + ${{ steps.setup-python.outputs.python-path }} -m pip install "${SCITT_PIP_INSTALL}" + - name: Create statement + shell: bash -xeuo pipefail {0} + env: + ISSUER: ${{ inputs.issuer }} + PAYLOAD: ${{ inputs.payload }} + SUBJECT: ${{ inputs.subject }} + PRIVATE_KEY_PEM: ${{ inputs.private-key-pem }} + PAYLOAD_CONTENT_TYPE: ${{ inputs.payload-content-type }} + run: | + "$(dirname ${{ steps.setup-python.outputs.python-path }})/scitt-emulator" client create-claim --issuer "${ISSUER}" --subject "${SUBJECT}" --content-type "${PAYLOAD_CONTENT_TYPE}" --payload "${PAYLOAD}" --out statement.cbor --private-key-pem "${PRIVATE_KEY_PEM}" + - name: Submit statement + shell: bash -xeuo pipefail {0} + id: submit-statement + env: + SCITT_URL: ${{ inputs.scitt-url }} + run: | + "$(dirname ${{ steps.setup-python.outputs.python-path }})/scitt-emulator" client submit-claim --url "${SCITT_URL}" --claim statement.cbor --out statement.receipt.cbor 2>&1 | tee >(grep Entry\ ID: | awk '{print $NF}' > entry_id.txt) + echo "entry-id=$(cat entry_id.txt)" >> "${GITHUB_OUTPUT}"