-
Notifications
You must be signed in to change notification settings - Fork 3
40 lines (40 loc) · 1.3 KB
/
backup.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Automatically backup the lists
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * SUN"
push:
paths:
- './script.ps1'
jobs:
RunScript:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Load secrets to environment variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Run PowerShell script
shell: pwsh
run: ./script.ps1
- name: Commit changes
shell: pwsh
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Tell git to add all XML file to staging, ignore if file contains "Scrape failed" inside
Get-ChildItem -Path "*" -Filter "*.xml" -File -Recurse | ForEach-Object {
$inside = Get-Content $_.FullName
if ($inside -contains "Scrape failed") {
Write-Host "Skipping file: $_"
} else {
git add $_.FullName
}
}
Get-ChildItem -Path "*" -Exclude "*.xml" -File -Recurse | ForEach-Object {
git add $_.FullName
}
git commit -m "Backup lists, $(Get-Date -AsUtc -Format 'yyyy-MM-ddTHH:mm:ssZ')"
git push