Skip to content

regen-answers

regen-answers #16

name: regen-answers
on:
workflow_dispatch:
schedule:
- cron: "0 1 * * *"
permissions: {}
jobs:
regenerate-answers:
name: regenerate answers
runs-on: ubuntu-latest
if: github.repository == 'chainguard-dev/vulnerability-scanner-support'
permissions:
contents: read # To clone the repo
id-token: write # To gitsign and federate
steps:
- uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: ${{ github.repository }}
identity: regen-answers
- name: Run hack/regen-answers.sh
id: regen-answers
uses: wolfi-dev/wolfi-act@d78f3659c50c4520e222df428f4903a1c4b0c6ee # main
with:
packages: grype,jq,perl,util-linux-misc,wolfictl
command: ./hack/regen-answers.sh
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
- name: Determine if there is a diff
shell: bash
id: check-diff
run: |
set -x
# Check if there is a diff
if git diff --exit-code data/answers.json; then
echo "No diff detected. Exiting"
echo "create_pr_update=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "create_pr_update=true" >> $GITHUB_OUTPUT
# Configure signed commits
- uses: chainguard-dev/actions/setup-gitsign@ba1a9c9ffe799736883d58f31caff18d85b2800e # main
if: ${{ steps.check-diff.outputs.create_pr_update == 'true' }}
# Based on usage in https://github.com/chainguard-dev/digestabot/blob/main/action.yml
- name: Create Pull Request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
if: ${{ steps.check-diff.outputs.create_pr_update == 'true' }}
id: pull_request
with:
add-paths: |
data/answers.json
token: "${{ steps.octo-sts.outputs.token }}"
commit-message: "automated: Regenerate data/answers.json"
title: "Regenerate data/answers.json"
body: |
Changes generated by https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
labels: automated pr
branch: regen-answers
signoff: true
author: "octo-sts[bot] <157150467+octo-sts[bot]@users.noreply.github.com>"
committer: "octo-sts[bot] <157150467+octo-sts[bot]@users.noreply.github.com>"
delete-branch: true