-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create reusable service provider action
Related to #140 but doesn't fix it until we can get the resulting JSON
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Check pinning service compliance | ||
on: | ||
# This workflow should be required for 'test & maybe release' to succeed | ||
# see https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow | ||
workflow_call: | ||
inputs: | ||
API_ENDPOINT: | ||
description: 'The API endpoint for the Pinning Service you want to use' | ||
type: string | ||
required: true | ||
fail_action_on_compliance_failure: | ||
description: 'Whether you want the action to fail if a compliance check fails' | ||
type: boolean | ||
default: true | ||
required: false | ||
secrets: | ||
API_TOKEN: | ||
required: true | ||
|
||
workflow_dispatch: | ||
inputs: | ||
type: | ||
description: 'Emulate either schedule, push, or pull_request' | ||
required: true | ||
default: 'schedule' | ||
type: choice | ||
options: | ||
- schedule | ||
- push | ||
- pull_request | ||
API_TOKEN: | ||
description: 'The API token for the Pinning Service you want to use' | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
|
||
check-provided-service-compliance: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v3 | ||
- uses: ipfs/aegir/actions/cache-node-modules@master | ||
- name: Reports Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: docs | ||
key: ${{ github.sha }} | ||
- run: npm run dev-start -- -s ${{ inputs.API_ENDPOINT }} ${{ secrets.API_TOKEN }} | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: docs | ||
path: docs | ||
- name: Set outputs | ||
id: set_results | ||
run: | | ||
hostname="$( echo ${{inputs.API_ENDPOINT}} | perl -ne '/^[^\/]+[\/]+([^\/]+)/ && print $1')" | ||
echo "::set-output name=success::$(jq -r '.success' docs/$hostname.json)" | ||
echo "::set-output name=passed::$(jq -r '.passed' docs/$hostname.json)" | ||
echo "::set-output name=total::$(jq -r '.total' docs/$hostname.json)" | ||
- name: Notify | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.notice('${{ needs.run-compliance-tests.outputs.passed }}/${{ needs.run-compliance-tests.outputs.total}} checks passed') | ||
validate-compliance: | ||
runs-on: ubuntu-latest | ||
needs: check-provided-service-compliance | ||
if: ${{ inputs.fail_action_on_compliance_failure && needs.run-compliance-tests.outputs.success != true }} | ||
steps: | ||
- name: Fail | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('Only ${{ needs.run-compliance-tests.outputs.passed }}/${{ needs.run-compliance-tests.outputs.total}} checks passed') |