mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
bad337a637
* nightly: add OCP build to catch breaking changes Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> * nightly: add Regal build + e2e test run w/ opa main Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> * .github: Add linter ignores for secrets-outside-env. Signed-off-by: Philip Conrad <philip@chariot-chaser.net> --------- Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> Signed-off-by: Philip Conrad <philip@chariot-chaser.net> Co-authored-by: Philip Conrad <philip@chariot-chaser.net>
129 lines
4.9 KiB
YAML
129 lines
4.9 KiB
YAML
name: Update Regal Docs
|
|
on:
|
|
workflow_dispatch: {} # Allow for manual triggers
|
|
schedule:
|
|
- cron: '0 6 * * *' # Daily at 6:00 UTC
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
update-regal-docs:
|
|
name: Update Regal Documentation
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
token: ${{ secrets.GH_PUSH_TOKEN }} # zizmor: ignore[secrets-outside-env]
|
|
persist-credentials: false
|
|
|
|
- name: Get latest Regal release
|
|
id: latest
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} # zizmor: ignore[secrets-outside-env]
|
|
run: |
|
|
LATEST_VERSION=$(gh api repos/open-policy-agent/regal/releases/latest --jq '.tag_name')
|
|
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
|
echo "Latest Regal version: $LATEST_VERSION"
|
|
|
|
- name: Get current version
|
|
id: current
|
|
run: |
|
|
CURRENT_VERSION=$(jq -r '.regal' docs/imported.json)
|
|
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
echo "Current Regal version: $CURRENT_VERSION"
|
|
|
|
- name: Check if update needed
|
|
id: check
|
|
run: |
|
|
if [ "${STEPS_LATEST_OUTPUTS_VERSION}" = "${STEPS_CURRENT_OUTPUTS_VERSION}" ]; then
|
|
echo "Already at latest version, no update needed"
|
|
echo "needed=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Update needed: ${STEPS_CURRENT_OUTPUTS_VERSION} -> ${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
echo "needed=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
STEPS_CURRENT_OUTPUTS_VERSION: ${{ steps.current.outputs.version }}
|
|
|
|
- name: Check if branch already exists
|
|
if: steps.check.outputs.needed == 'true'
|
|
run: |
|
|
BRANCH_NAME="update-regal-${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
|
|
echo "::error::Branch '$BRANCH_NAME' already exists. A PR for this version may already be open."
|
|
exit 1
|
|
fi
|
|
echo "Branch '$BRANCH_NAME' does not exist, proceeding with update"
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
|
|
- name: Update imported.json
|
|
if: steps.check.outputs.needed == 'true'
|
|
run: |
|
|
jq --arg version "${STEPS_LATEST_OUTPUTS_VERSION}" '.regal = $version' docs/imported.json > docs/imported.json.tmp
|
|
mv docs/imported.json.tmp docs/imported.json
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
|
|
- name: Run import script
|
|
if: steps.check.outputs.needed == 'true'
|
|
run: |
|
|
cd docs
|
|
VERSION=${STEPS_LATEST_OUTPUTS_VERSION} ./bin/import-regal-docs.sh
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
|
|
- name: Check for changes
|
|
if: steps.check.outputs.needed == 'true'
|
|
id: changes
|
|
run: |
|
|
if git diff --quiet; then
|
|
echo "No changes detected after import"
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Changes detected"
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Configure git
|
|
if: steps.check.outputs.needed == 'true' && steps.changes.outputs.has_changes == 'true'
|
|
run: |
|
|
git config user.name "opa-docs-bot"
|
|
git config user.email "opa-docs-bot@openpolicyagent.org"
|
|
|
|
- name: Create branch and commit
|
|
if: steps.check.outputs.needed == 'true' && steps.changes.outputs.has_changes == 'true'
|
|
run: |
|
|
BRANCH_NAME="update-regal-${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
git checkout -b "$BRANCH_NAME"
|
|
git add -A
|
|
git commit -s -m "docs: Update Regal docs to ${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
|
|
- name: Push branch
|
|
if: steps.check.outputs.needed == 'true' && steps.changes.outputs.has_changes == 'true'
|
|
run: |
|
|
BRANCH_NAME="update-regal-${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
git push origin "$BRANCH_NAME"
|
|
env:
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
|
|
- name: Create pull request
|
|
if: steps.check.outputs.needed == 'true' && steps.changes.outputs.has_changes == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} # zizmor: ignore[secrets-outside-env]
|
|
STEPS_LATEST_OUTPUTS_VERSION: ${{ steps.latest.outputs.version }}
|
|
run: |
|
|
VERSION="${STEPS_LATEST_OUTPUTS_VERSION}"
|
|
gh pr create \
|
|
--title "docs: Update Regal docs to $VERSION" \
|
|
--body "$(cat <<EOF
|
|
This PR updates the Regal documentation to $VERSION.
|
|
EOF
|
|
)" \
|
|
--reviewer charlieegan3,anderseknert
|