Skip to content

Refine CLI for use with get_table as almanack <repo path> #164

Refine CLI for use with get_table as almanack <repo path>

Refine CLI for use with get_table as almanack <repo path> #164

Workflow file for this run

# Used for displaying an entropy report for every PR opened to main
---
name: entropy-check
on:
# note: changed from pull_request_target to help enable if conditional
# for workflow.
pull_request:
branches: [main]
workflow_dispatch:
jobs:
entropy-check:
# only run if the PR head branch is named 'fix-gh-actions-pr-report'
if: github.ref == 'refs/heads/fix-gh-actions-pr-report'
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch the entire history of commits
- name: Install python env
uses: ./.github/actions/install-python-env
with:
fetch-depth: 0 # Ensure the action respects the desired fetch depth
# Determine the PR branches and set environment variables
- name: Set PR Branch Environment Variables
env:
PR_BRANCH: ${{ github.head_ref }}
MAIN_BRANCH: ${{ github.base_ref }}
run: |
"echo 'PR_BRANCH=${PR_BRANCH}' >> $GITHUB_ENV"
"echo 'MAIN_BRANCH=${MAIN_BRANCH}' >> $GITHUB_ENV"
# Runs the entropy calculation script and saves the output to a file
- name: Process repository entropy
run: |
"poetry run almanack process_pr_entropy \
--repo_path '.' \
--pr_branch '${{ env.PR_BRANCH }}' \
--main_branch '${{ env.MAIN_BRANCH }}' > entropy_report.txt"
# Formats the entropy report and saves it to GitHub Actions env
- name: Format Entropy Report
run: |
{
echo "REPORT_CONTENT<<EOF";
echo "\`\`\`";
cat entropy_report.txt;
echo "\`\`\`";
echo "EOF";
} >> "$GITHUB_ENV"
- name: PR comment
uses: thollander/actions-comment-pull-request@v3
with:
message: |
${{ env.REPORT_CONTENT }}
comment_tag: execution
mode: recreate # Recreates the comment if it already exists