Skip to content

regen-answers

regen-answers #2

name: regen-answers
on:
workflow_dispatch:
schedule:
- cron: "0 1 * * *"
permissions:
contents: read
id-token: write # Needed to federate tokens.
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@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
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
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
with:
packages: grype,jq,perl,util-linux-misc,wolfictl
command: ./hack/regen-answers.sh
- name: Determine if there is a diff
shell: bash
id: check-diff
run: |
set -x
# Check if there is a diff
if git diff-index --quiet HEAD --; 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@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
if: ${{ steps.check-diff.outputs.create_pr_update == 'true' }}
id: pull_request
with:
token: "regen-answers"
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
committer: "GitHub <[email protected]>"
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
delete-branch: true