generated from copilot-workshops/copilot-node-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec14e9d
commit 1011002
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
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 |