regen-answers #8
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
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@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3 | |
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 | |
committer: "157150467+octo-sts[bot]@users.noreply.github.com" | |
author: "octo-sts[bot]" | |
delete-branch: true |