Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
palisadoes committed Dec 31, 2024
1 parent ac63cd4 commit dcf43b1
Showing 1 changed file with 76 additions and 76 deletions.
152 changes: 76 additions & 76 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,93 +16,93 @@ on:
- '**'

jobs:
Code-Quality-Checks:
name: Performs linting, formatting, type-checking, checking for different source and target branch
runs-on: ubuntu-latest
steps:
- name: Check if the source and target branches are different
if: ${{ github.event.pull_request.base.ref == github.event.pull_request.head.ref }}
run: |
echo "Source Branch ${{ github.event.pull_request.head.ref }}"
echo "Target Branch ${{ github.event.pull_request.base.ref }}"
echo "Error: Source and Target Branches are the same. Please ensure they are different."
exit 1
# Code-Quality-Checks:
# name: Performs linting, formatting, type-checking, checking for different source and target branch
# runs-on: ubuntu-latest
# steps:
# - name: Check if the source and target branches are different
# if: ${{ github.event.pull_request.base.ref == github.event.pull_request.head.ref }}
# run: |
# echo "Source Branch ${{ github.event.pull_request.head.ref }}"
# echo "Target Branch ${{ github.event.pull_request.base.ref }}"
# echo "Error: Source and Target Branches are the same. Please ensure they are different."
# exit 1

Check-Sensitive-Files:
if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }}
name: Checks if sensitive files have been changed without authorization
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Check-Sensitive-Files:
# if: ${{ github.actor != 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'ignore-sensitive-files-pr') }}
# name: Checks if sensitive files have been changed without authorization
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

- name: Get Changed Unauthorized files
id: changed-unauth-files
uses: tj-actions/changed-files@v45
with:
files: |
.github/**
CNAME
static/CNAME
package.json
sidebar*.js
docusaurus.config.js
babel.config.js
CODEOWNERS
LICENSE
./*md
package-lock.json
tsconfig.json
yarn.lock
static/.nojekyll
tsconfig.json
.gitignore
babel.config.js
# - name: Get Changed Unauthorized files
# id: changed-unauth-files
# uses: tj-actions/changed-files@v45
# with:
# files: |
# .github/**
# CNAME
# static/CNAME
# package.json
# sidebar*.js
# docusaurus.config.js
# babel.config.js
# CODEOWNERS
# LICENSE
# ./*md
# package-lock.json
# tsconfig.json
# yarn.lock
# static/.nojekyll
# tsconfig.json
# .gitignore
# babel.config.js

- name: List all changed unauthorized files
if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true'
env:
CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
run: |
for file in ${CHANGED_UNAUTH_FILES}; do
echo "$file is unauthorized to change/delete"
done
echo "To override this, apply the 'ignore-sensitive-files-pr' label"
exit 1
# - name: List all changed unauthorized files
# if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true'
# env:
# CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
# run: |
# for file in ${CHANGED_UNAUTH_FILES}; do
# echo "$file is unauthorized to change/delete"
# done
# echo "To override this, apply the 'ignore-sensitive-files-pr' label"
# exit 1

Count-Changed-Files:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Checks if number of files changed is acceptable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Count-Changed-Files:
# if: ${{ github.actor != 'dependabot[bot]' }}
# name: Checks if number of files changed is acceptable
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
# - name: Get changed files
# id: changed-files
# uses: tj-actions/changed-files@v45

- name: Echo number of changed files
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Number of files changed: $CHANGED_FILES_COUNT"
# - name: Echo number of changed files
# env:
# CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
# run: |
# echo "Number of files changed: $CHANGED_FILES_COUNT"

- name: Check if the number of changed files is less than 100
if: steps.changed-files.outputs.all_changed_files_count > 100
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Error: Too many files (greater than 100) changed in the pull request."
echo "Possible issues:"
echo "- Contributor may be merging into an incorrect branch."
echo "- Source branch may be incorrect please use develop as source branch."
exit 1
# - name: Check if the number of changed files is less than 100
# if: steps.changed-files.outputs.all_changed_files_count > 100
# env:
# CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
# run: |
# echo "Error: Too many files (greater than 100) changed in the pull request."
# echo "Possible issues:"
# echo "- Contributor may be merging into an incorrect branch."
# echo "- Source branch may be incorrect please use develop as source branch."
# exit 1

Test-Docusaurus-Deployment:
name: Test Deployment to https://docs.talawa.io
runs-on: ubuntu-latest
needs: [Code-Quality-Checks]
# needs: [Code-Quality-Checks]
# Run only if the develop branch and not dependabot
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.base.ref == 'develop' }}
steps:
Expand Down

0 comments on commit dcf43b1

Please sign in to comment.