Skip to content

New Forked PR

New Forked PR #14

name: 02-Check-Readme-Structure
on:
pull_request_target:
types: [opened, synchronize, edited]
# permissions:
# contents: read
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
type: string
default: 'master'
jobs:
ci-check:
name: Check README Structure
runs-on: ubuntu-latest
steps:
- name: Trigger
run: echo "Triggered by ${{github.event_name}} event"
- name: Check Branch Input
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ -z "${{ github.event.inputs.branch }}" ]; then
echo "Branch input is required for manual trigger."
exit 1
fi
fi
- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout tools repository
uses: actions/checkout@v4
with:
repository: SiliconLabsSoftware/aep_ci_tools
ref: 'hop_dev'
token: ${{ steps.app-token.outputs.token }}
path: 'aep_ci_tools'
- name: Checkout base repository code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
path: 'projects'
- name: Fetch head and base refs
# This is necessary to check the changes in the PR branch
run: |
cd projects
git fetch origin ${{ github.base_ref }}:base_ref
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref
- name: Check the change
run: |
cd projects
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --diff-filter=ACMR --name-only | grep '/' | cut -d'/' -f1 | sort | uniq > git_log.txt
grep -v "README.md\\|.github\\|LICENSE\\|templates.xml\\|deprecated" git_log.txt > changed_projects_folder.txt
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --diff-filter=ACMR --name-only > git_diff.txt
xargs -I{} -a git_diff.txt find {} -type f -name "*.[ch]" > source_list.txt
xargs -I{} -a git_diff.txt find {} -type f -name "*.slcp" > solution_list.txt
if ! [ -s source_list.txt -o -s solution_list.txt ]; then
echo "No changes to check."
exit 0
fi
# For debug
echo ====================
cat git_diff.txt
echo ====================
cat changed_projects_folder.txt
- name: Run test
run : |
cd projects
bash ${{ github.workspace }}/aep_ci_tools/scripts/check_readme_file_v2.sh git_diff.txt > readme_file_report.html
- name: Upload Result
uses: actions/upload-artifact@v4
with:
name: readme_file_report
path: projects/readme_file_report.html
retention-days: 90
- name: Check log file to set status of the job
run: |
cd projects
if grep -qe "Fail" readme_file_report.html; then
echo "Result: Failure"
exit 1
else
echo "Result: Success"
fi