Skip to content

Migration build

Migration build #7

name: Build and Test Actionbot
on:
push:
branches:
- main
pull_request:
types:
- opened
- edited
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: '20'
- run: npm install
- run: npm run build
- run: npm run package
test-allow-policy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test Allow Policy
uses: ./ # Use the action from the current repository
with:
policy: 'allow'
policy-url: 'https://github.com/Contrast-Security-OSS/actionbot/blob/main/example_allow_policy.json' # Replace with your allow policy URL
github-token: ${{ secrets.ACTIONBOT_GITHUB_PAT }}
fail-if-violations: 'true'
- name: Respond to action policy violations
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: steps.Actionbot.outputs.violations
with:
github-token: ${{ secrets.ACTIONBOT_GITHUB_PAT }}
script: |
const violations = JSON.parse(steps.actionbot.outputs.violations);
console.log('Violations found:', violations);
test-prohibit-policy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test Prohibit Policy
uses: ./
with:
policy: 'prohibit'
policy-url: 'https://github.com/Contrast-Security-OSS/actionbot/blob/main/example_prohibit_policy.json' # Replace with your prohibit policy URL
github-token: ${{ secrets.ACTIONBOT_GITHUB_PAT }}
fail-if-violations: 'true'
- name: Respond to action policy violations
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: steps.Actionbot.outputs.violations
with:
github-token: ${{ secrets.ACTIONBOT_GITHUB_PAT }}
script: |
const violations = JSON.parse(steps.actionbot.outputs.violations);
console.log('Violations found:', violations);