-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a1c154
commit 1775778
Showing
1 changed file
with
21 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
name: Fetch and Backup Data | ||
name: Fetch and Save Data | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" # Every Sunday at midnight UTC | ||
- cron: '0 0 * * 1' # Run every Monday at midnight | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
fetch-and-backup: | ||
fetch-and-save-data: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '14' | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Fetch and backup data | ||
- name: Fetch and Save Data | ||
run: | | ||
fetch('https://vdnh.ru/local/templates/v3_new_header/js/places-s1.js') | ||
.then(response => response.text()) | ||
.then(data => { | ||
const jsonData = data.replace(/^var places = |;$/g, ''); | ||
const backupData = JSON.stringify(jsonData, null, 2); | ||
node -e "const fetch = require('node-fetch'); \ | ||
const fs = require('fs'); \ | ||
fetch('https://vdnh.ru/local/templates/v3_new_header/js/places-s1.js') \ | ||
.then(response => response.text()) \ | ||
.then(data => { \ | ||
const jsonData = data.replace(/^var places = |;$/g, ''); \ | ||
const backupData = JSON.stringify(jsonData, null, 2); \ | ||
fs.writeFileSync('backup.json', backupData); \ | ||
}) \ | ||
.catch(error => { \ | ||
console.error('Error fetching data:', error); \ | ||
process.exit(1); \ | ||
})" | ||
require('fs').writeFileSync('backup.json', backupData); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching data:', error); | ||
process.exit(1); | ||
}) |