Skip to content

Commit

Permalink
Create secure_assets.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
stargazer4 authored May 2, 2024
1 parent ec14e9d commit 1011002
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/secure_assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check for assets

on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
pull_request:
types: [opened, edited]

jobs:
check-assets:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Check for assets
uses: actions/github-script@v5
with:
script: |
const issueOrPrBody = context.payload.issue?.body || context.payload.pull_request?.body || context.payload.comment?.body;
if (issueOrPrBody.includes('/assets')) {
const fs = require('fs');
const issueOrPrLink = context.payload.issue?.html_url || context.payload.pull_request?.html_url || context.payload.comment?.html_url;
const repoName = context.repo.repo;
fs.writeFileSync('assets.txt', `Issue/PR link: ${issueOrPrLink}\nRepo name: ${repoName}`);
}
- name: Commit and push if changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Add assets.txt"
git push
fi

0 comments on commit 1011002

Please sign in to comment.