Monitor and Sync ps2exe.ps1 from another repository #4
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: Monitor and Sync ps2exe.ps1 from another repository | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Tägliche Überprüfung um Mitternacht | |
workflow_dispatch: # Manuelle Ausführung möglich | |
jobs: | |
check-and-sync: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Check out this repository | |
- name: Check out this repository | |
uses: actions/checkout@v4 | |
# 2. Download ps2exe.ps1 from the external repository | |
- name: Download ps2exe.ps1 from Win-PS2EXE | |
run: | | |
curl -s https://raw.githubusercontent.com/MScholtes/Win-PS2EXE/master/ps2exe.ps1 -o external_ps2exe.ps1 | |
# 3. Check if ps2exe.ps1 exists in your repository | |
- name: Check if ps2exe.ps1 exists | |
id: file_check | |
run: | | |
if [ -f src/ps2exe.ps1 ]; then | |
echo "ps2exe.ps1 exists." | |
echo "exists=true" >> $GITHUB_ENV | |
else | |
echo "ps2exe.ps1 does not exist." | |
echo "exists=false" >> $GITHUB_ENV | |
fi # Hier das 'fi' hinzufügen | |
# 4. If the file exists, compare it with the external version | |
- name: Compare the two files | |
if: env.exists == 'true' | |
id: file_compare | |
run: | | |
if diff src/ps2exe.ps1 external_ps2exe.ps1; then | |
echo "No differences found" | |
echo "changed=false" >> $GITHUB_ENV | |
else | |
echo "Differences found" | |
echo "changed=true" >> $GITHUB_ENV | |
fi # Hier das 'fi' hinzufügen | |
# 5. If the file does not exist or there are changes, overwrite and commit | |
- name: Handle missing or changed ps2exe.ps1 | |
if: env.exists == 'false' || env.changed == 'true' | |
run: | | |
echo "Updating ps2exe.ps1 in repository." | |
mv external_ps2exe.ps1 src/ps2exe.ps1 # Overwrite the file or add it if missing | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git add -f src/ps2exe.ps1 | |
git commit -m "Update ps2exe.ps1 from Win-PS2EXE" | |
git push origin main | |
# 6. Create a Pull Request if changes were made | |
- name: Create a pull request | |
if: env.changed == 'true' || env.exists == 'false' | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Sync ps2exe.ps1 from Win-PS2EXE" | |
branch: sync-ps2exe-update | |
title: "Update ps2exe.ps1 from upstream repository" | |
body: "Automated pull request to sync the latest changes from Win-PS2EXE repository." |