new Workflow
This commit is contained in:
parent
463fb7370f
commit
955f510f7b
83
.github/workflows/delete_new_script.yaml
vendored
Normal file
83
.github/workflows/delete_new_script.yaml
vendored
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
name: Delete Files on Issue Close (With Existence Check)
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
delete-files:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: contains(github.event.issue.labels.*.name, 'Migration To ProxmoxVE')
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract Issue Title
|
||||||
|
id: extract_title
|
||||||
|
run: echo "TITLE=$(echo '${{ github.event.issue.title }}' | sed 's/ /_/g')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Check if Files Exist in community-scripts/ProxmoxVE
|
||||||
|
id: check_files
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
REPO="community-scripts/ProxmoxVE"
|
||||||
|
API_URL="https://api.github.com/repos/$REPO/contents"
|
||||||
|
|
||||||
|
FILES=(
|
||||||
|
"ct/${TITLE}.sh"
|
||||||
|
"install/${TITLE}-install.sh"
|
||||||
|
"json/${TITLE}.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
EXISTS=false
|
||||||
|
for FILE in "${FILES[@]}"; do
|
||||||
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GH_TOKEN" "$API_URL/$FILE")
|
||||||
|
if [ "$STATUS" -eq 200 ]; then
|
||||||
|
EXISTS=true
|
||||||
|
echo "$FILE exists in $REPO"
|
||||||
|
else
|
||||||
|
echo "$FILE does NOT exist in $REPO"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$EXISTS" = false ]; then
|
||||||
|
echo "No matching files found in $REPO. Exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Delete Files
|
||||||
|
run: |
|
||||||
|
rm -f ct/${TITLE}.sh
|
||||||
|
rm -f install/${TITLE}-install.sh
|
||||||
|
rm -f json/${TITLE}.json
|
||||||
|
|
||||||
|
- name: Commit and Push Changes
|
||||||
|
run: |
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add .
|
||||||
|
if git diff --staged --quiet; then
|
||||||
|
echo "No files to delete. Exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git commit -m "Deleted files for issue: ${{ github.event.issue.title }}"
|
||||||
|
git push origin main
|
||||||
|
echo "COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Comment on Issue
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
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}).`;
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue_number,
|
||||||
|
body: message
|
||||||
|
});
|
1
ct/snipeit.sh
Normal file
1
ct/snipeit.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
1
install/snipeit-install.sh
Normal file
1
install/snipeit-install.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
0
json/snipeit.json
Normal file
0
json/snipeit.json
Normal file
Loading…
x
Reference in New Issue
Block a user