This commit is contained in:
Michel Roegl-Brunner 2025-03-13 11:50:20 +01:00
parent 064f2faf20
commit 52e8bf9ba5

View File

@ -50,22 +50,28 @@ jobs:
- name: Delete Files - name: Delete Files
run: | run: |
rm -f ct/${TITLE}.sh
rm -f install/${TITLE}-install.sh
rm -f json/${TITLE}.json
- name: Commit and Push Changes - name: Commit and Push Changes
run: | run: |
branch=$(echo "delete-files_${{ github.event.issue.number }}_${TITLE}" | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g')
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b $branch
rm -f ct/${TITLE}.sh
rm -f install/${TITLE}-install.sh
rm -f json/${TITLE}.json
git add . git add .
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No files to delete. Exiting..." echo "No files to delete. Exiting..."
exit 0 exit 0
fi fi
git commit -m "Deleted files for issue: ${{ github.event.issue.title }}" git commit -m "Deleted files for issue: ${{ github.event.issue.title }}"
git push origin main git push origin branch
echo "COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV gh pr create --title "Delete Files for Issue: ${{ github.event.issue.title }}" --body "Files deleted and committed in $COMMIT_SHA." --base main --head $branch
pr_number=$(gh pr list | grep -m 1 $branch | awk '{print $1}')
#gh pr merge $pr_number --squash
echo pr_number=$pr_number >> $GITHUB_ENV
- name: Comment on Issue - name: Comment on Issue
uses: actions/github-script@v7 uses: actions/github-script@v7
@ -73,8 +79,8 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
const issue_number = context.payload.issue.number; const issue_number = context.payload.issue.number;
const commit_sha = process.env.COMMIT_SHA;
const message = `Files deleted and committed in [${commit_sha}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${commit_sha}).`; const message = `Files deleted with PR_#${process.env.pr_number}.`;
github.rest.issues.createComment({ github.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,