116 lines
3.3 KiB
YAML
116 lines
3.3 KiB
YAML
name: Move new Scripts to Main Repository
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
move-to-main-repo:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
actions: write
|
|
|
|
steps:
|
|
- name: Generate a token
|
|
id: generate-token
|
|
uses: actions/create-github-app-token@v1
|
|
with:
|
|
app-id: ${{ vars.APP_ID }}
|
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
|
|
- name: List Issues in Repository
|
|
id: list_issues
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
echo "Filtering Issues with Label MigrationTest"
|
|
|
|
raw_output=$(gh issue list --json title,labels)
|
|
echo "$raw_output"
|
|
|
|
filtered_issues=$(echo "$raw_output" | jq -r '.[] | select(.labels[]?.name == "MigrationTest") | .title')
|
|
if [ -z "$filtered_issues" ]; then
|
|
echo "No issues found with label 'MigrationTest'."
|
|
else
|
|
|
|
echo "Found script names with 'MigrationTest' label:"
|
|
echo "$filtered_issues"
|
|
for script_name in $filtered_issues; do
|
|
echo "Processing: $script_name"
|
|
script_name_lowercase=$(echo "$script_name" | tr '[:upper:]' '[:lower:]')
|
|
echo "Lowercase script name: $script_name_lowercase"
|
|
echo "script_name=$script_name_lowercase" >> $GITHUB_ENV
|
|
done
|
|
fi
|
|
|
|
- name: Check if script files exist
|
|
id: check_files
|
|
run: |
|
|
|
|
ct_file="ct/${script_name}.sh"
|
|
install_file="install/${script_name}-install.sh"
|
|
json_file="json/${script_name}.json"
|
|
|
|
if [[ -f "$ct_file" && -f "$install_file" && -f "$json_file" ]]; then
|
|
echo "All required files found."
|
|
echo "files_found=true" >> $GITHUB_ENV
|
|
else
|
|
echo "Not all required files were found."
|
|
echo "files_found=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Configure Git user
|
|
run: |
|
|
git config --global user.email "github-actions@github.com"
|
|
git config --global user.name "GitHub Actions"
|
|
|
|
- name: Create PR if files found
|
|
if: env.files_found == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.MAIN_REPO_WF }}
|
|
run: |
|
|
script_name="wf-test"
|
|
|
|
target_repo="community-scripts/ProxmoxVE"
|
|
|
|
branch_name="add-script-$script_name-$(date +'%Y%m%d%H%M%S')"
|
|
|
|
commit_message="Add script files for $script_name"
|
|
|
|
|
|
git checkout -b "$branch_name"
|
|
|
|
|
|
|
|
cp "ct/$script_name.sh" .
|
|
cp "install/$script_name-install.sh" .
|
|
cp "json/$script_name.json" .
|
|
|
|
git add .
|
|
|
|
git commit -m "$commit_message"
|
|
|
|
git status
|
|
|
|
git push origin "$branch_name"
|
|
|
|
git remote add upstream https://github.com/${target_repo}.git
|
|
|
|
git fetch upstream
|
|
|
|
git status
|
|
|
|
unset GH_TOKEN
|
|
|
|
echo ${{ secrets.MAIN_REPO_WF }} > mytoken.txt
|
|
|
|
gh auth login --with-token < mytoken.txt
|
|
|
|
gh pr create --title "Add script files for $script_name" --body "This PR adds the $script_name script files." --base main --head "community-scripts/ProxmoxVED:$branch_name" --repo "${target_repo}"
|