Sync and Run Other Repo Releases #9
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
name: Sync and Run Other Repo Releases | |
permissions: | |
contents: write | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 매일 자정 (00:00)에 실행되도록 설정 | |
workflow_dispatch: # 수동으로 실행할 수 있도록 설정 | |
jobs: | |
download_and_run: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
with: | |
# Personal Access Token으로 push 권한 설정 | |
token: ${{ secrets.GIT_PAT }} | |
- name: Configure Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Get all releases from another repo | |
run: | | |
$repo = "armoha/euddraft" #euddraft repo | |
$releases_url = "https://api.github.com/repos/$repo/releases" | |
# 다른 사람의 릴리즈 목록 가져오기 | |
$releases = (Invoke-RestMethod -Uri $releases_url).tag_name | |
# 내 레포지토리에서 이미 처리된 릴리즈 확인 | |
$processed_releases = git tag --list | |
Write-Host "Processed releases: $processed_releases" | |
# 각 릴리즈마다 작업 수행 | |
foreach ($release in $releases) { | |
if ($processed_releases -contains $release) { | |
Write-Host "Skipping $release" | |
continue | |
} | |
$zip_name = "euddraft$release.zip" -replace "euddraftv", "euddraft" | |
$exe_name = "euddraft.exe" | |
$json_name = "$release.json" | |
$zip_url = "https://github.com/$repo/releases/download/$release/$zip_name" | |
$zip_output = "$zip_name" | |
$exe_output_folder = "$zip_output" -replace ".zip", "" | |
# zip 파일 다운로드 | |
Invoke-WebRequest -Uri $zip_url -OutFile $zip_output | |
if (Test-Path $zip_name) { | |
# zip 파일 압축 풀기 | |
Write-Host "Extracting $zip_name" | |
Expand-Archive -Path $zip_output -DestinationPath $exe_output_folder -Force | |
# 압축이 풀린 폴더에서 exe 파일 찾기 | |
$exe_path = Get-ChildItem -Path $exe_output_folder -Filter "$exe_name" | Select-Object -First 1 | |
if ($exe_path) { | |
Write-Host "Running $exe_name" | |
# exe 파일 실행 | |
cmd /c $exe_path.FullName '.\src\EUDEditor.eds' | |
if (Test-Path $json_name) { | |
Remove-Item -Path $json_name -Force | |
} | |
Rename-Item -Path '.\output.json' -NewName $json_name -Force | |
# 실행 후 JSON 파일 존재하는지 확인 | |
if (Test-Path $json_name) { | |
Write-Host "$json_name exists. Committing to repo." | |
# JSON 파일을 커밋하고 푸시 | |
git add $json_name | |
git commit -m "$release" | |
# 해당 릴리즈를 처리 완료로 기록 | |
git tag $release | |
git push origin main | |
git push --tags | |
} else { | |
Write-Host "JSON file not found after running $exe_name" | |
} | |
} else { | |
Write-Host "No exe file found in $zip_name" | |
} | |
} else { | |
Write-Host "No zip file found" | |
} | |
} |