Skip to content

Commit

Permalink
feat: create reusable service provider action
Browse files Browse the repository at this point in the history
Related to #140 but doesn't fix it until we can get the resulting JSON
  • Loading branch information
SgtPooki committed Jun 24, 2022
1 parent 0329c44 commit fdd5a67
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/check-compliance.yml
@@ -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')

0 comments on commit fdd5a67

Please sign in to comment.