-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (56 loc) · 2 KB
/
entropy-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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