Fixed Unauthorized Access By Manipulating Endpoints (#1854) #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
############################################################################## | |
# | |
# NOTE! | |
# | |
# Please read the README.md file in this directory that defines what should | |
# be placed in this file | |
# | |
############################################################################## | |
############################################################################## | |
name: push workflow | |
on: | |
push: | |
branches: | |
- '**' | |
env: | |
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }} | |
jobs: | |
Code-Coverage: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-code-coverage-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-code-coverage-${{ env.cache-name }}- | |
${{ runner.os }}-code-coverage- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
run: npm install | |
- run: npm run test -- --watchAll=false --coverage | |
- name: Present and upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}} | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
fail_ci_if_error: false | |
name: '${{env.CODECOV_UNIQUE_NAME}}' | |
Generate-Documentation: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/automated-docs' | |
steps: | |
- name: Checkout the Repository | |
uses: actions/checkout@v4 | |
# with: | |
# ref: develop | |
# - name: Pull latest changes from develop | |
# run: git pull origin develop | |
- name: Node.js Version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Restore node_modules from cache | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-generate-docs-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-generate-docs-${{ env.cache-name }}- | |
${{ runner.os }}-generate-docs- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm install | |
- name: Install TypeScript Globally and add GraphQL tag | |
run: yarn global add typescript | |
- run: yarn add graphql-tag | |
- name: Update Dependencies | |
run: yarn upgrade | |
- name: Generate Documentation of Markdown pages | |
run: | | |
npm install --global typedoc | |
npm install typedoc-plugin-markdown | |
npm install --save-dev @types/node | |
npx typedoc --entryPoints src/components src/screens --out talawa-admin-docs --plugin typedoc-plugin-markdown --theme markdown --entryPointStrategy expand --exclude "**/*.test.ts" --exclude "**/*.css" | |
- name: Make Markdown Files MDX Compatible | |
run: python ./.github/workflows/md_mdx_format_adjuster.py --directory talawa-admin-docs | |
- name: Checking doc updated | |
id: DocUpdated | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "updateDoc=true" >> $GITHUB_OUTPUT | |
echo -e "Documentation has been updated!!" | |
else | |
Green='0;32' | |
NoColor='\033[0m' | |
echo -e "${Green}No documentation updated${NoColor}" | |
fi | |
- name: Set env variables | |
if: steps.DocUpdated.outputs.updateDoc | |
run: | | |
echo "commit_id=$(echo $(git rev-parse HEAD))" >> $GITHUB_ENV | |
echo "email=$(echo $(git log --pretty=format:"%ae" $commit_id))" >> $GITHUB_ENV | |
- name: Update Doc | |
if: steps.DocUpdated.outputs.updateDoc | |
run: | | |
Green='0;32' | |
NoColor='\033[0m' | |
git config --global user.name "${{github.actor}}" | |
git config --global user.email "${{env.email}}" | |
git add . | |
git commit -m "Update documentation" | |
git push origin develop:automated-docs --force | |
echo -e "🚀${Green} Hurrah! doc updated${NoColor}" | |
- name: Create Documentation Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: documentation-admin | |
path: talawa-admin-docs | |
Empty-Commit: | |
name: Create Empty Commit | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/develop' | |
needs: Generate-Documentation | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
token: ${{ secrets.TALAWA_DOCS_SYNC }} | |
- name: Empty Commit | |
run: | | |
git config --global user.name "${{github.actor}}" | |
git config --global user.email "${{env.email}}" | |
git config --global url.https://${{ secrets.TALAWA_DOCS_SYNC }}@github.com/.insteadOf https://github.com/ | |
git commit --allow-empty -m "Trigger Documentation Workflow" | |
git push origin develop:automated-docs --force | |
Copy-docs-to-talawa-docs: | |
if: github.ref == 'refs/heads/automated-docs' | |
needs: Generate-Documentation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dmnemec/[email protected] | |
env: | |
API_TOKEN_GITHUB: ${{secrets.TALAWA_DOCS_SYNC}} | |
with: | |
source_file: 'talawa-admin-docs/' | |
destination_repo: 'PalisadoesFoundation/talawa-docs' | |
destination_branch: 'develop' | |
destination_folder: 'docs/' | |
user_email: '${{env.email}}' | |
user_name: '${{github.actor}}' | |
commit_message: 'Talawa Admin docs updated' |