mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
retry action automatically
This commit is contained in:
parent
ad01f99fc3
commit
ca71dba59c
2 changed files with 13 additions and 4 deletions
1
.github/workflows/sepa-precios-archiver.yml
vendored
1
.github/workflows/sepa-precios-archiver.yml
vendored
|
@ -23,6 +23,7 @@ jobs:
|
||||||
- name: Run archiver script
|
- name: Run archiver script
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.ARCHIVE_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.ARCHIVE_GITHUB_TOKEN }}
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PRECIAZO_TOKEN }}
|
||||||
B2_BUCKET_NAME: ${{ secrets.B2_BUCKET_NAME }}
|
B2_BUCKET_NAME: ${{ secrets.B2_BUCKET_NAME }}
|
||||||
B2_BUCKET_KEY_ID: ${{ secrets.B2_BUCKET_KEY_ID }}
|
B2_BUCKET_KEY_ID: ${{ secrets.B2_BUCKET_KEY_ID }}
|
||||||
B2_BUCKET_KEY: ${{ secrets.B2_BUCKET_KEY }}
|
B2_BUCKET_KEY: ${{ secrets.B2_BUCKET_KEY }}
|
||||||
|
|
|
@ -32,17 +32,25 @@ const s3 = new S3Client({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getRawDatasetInfo() {
|
async function getRawDatasetInfo(attempts = 0) {
|
||||||
try {
|
try {
|
||||||
return await $`curl -L https://datos.produccion.gob.ar/api/3/action/package_show?id=sepa-precios`.json();
|
return await $`curl -L https://datos.produccion.gob.ar/api/3/action/package_show?id=sepa-precios`.json();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (attempts >= 4) {
|
||||||
|
console.error(`❌ Error fetching dataset info`, error);
|
||||||
|
if (process.env.GITHUB_RUN_ID) {
|
||||||
|
console.info(`🔄 Retrying action`);
|
||||||
|
await $`gh run rerun ${process.env.GITHUB_RUN_ID} --workflow sepa-precios-archiver`;
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
console.error(
|
console.error(
|
||||||
`❌ Error fetching dataset info`,
|
`❌ Error fetching dataset info`,
|
||||||
error,
|
error,
|
||||||
`retrying in 5min...`
|
`retrying in 30s...`
|
||||||
);
|
);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5 * 60 * 1000));
|
await new Promise((resolve) => setTimeout(resolve, 30 * 1000));
|
||||||
return await getRawDatasetInfo();
|
return await getRawDatasetInfo(attempts + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function saveFileIntoRepo(fileName: string, fileContent: string) {
|
async function saveFileIntoRepo(fileName: string, fileContent: string) {
|
||||||
|
|
Loading…
Reference in a new issue