Use Github Action to monitor page changes, success upload artifact today, but can't download it next day

182 Views Asked by At

I wrote a script to monitoring some pages' change daily.

It scrapy the page daily, save the result to csv files, and next day compare to new scrapied data, calc the diff, then mailed to meself.

The script works well on my VPS, now I'm trying to mig it to github action.

I created a workflow, as below:

name: job run
run-name: Check page change and mail the result.
on: 
  push:
  schedule:
    - cron: '0 10 * * *'
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '16'
      - name: Download all workflow run artifactsd
        uses: actions/download-artifact@v3
      - run: npm i
      - run: node monitor.js
      - uses: actions/upload-artifact@v3
        with:
          name: archive
          path: |
            cats_old.txt
            spider_old.csv

But it doesn't download artifacts uploaded before, which means 'compare' to nothing everyday.

Run actions/download-artifact@v3
No artifact name specified, downloading all artifacts
Creating an extra directory for each artifact that is being downloaded
Unable to find any artifacts for the associated workflow
There were 0 artifacts downloaded
Artifact download has finished successfully

I guess it because every day the job triggers, github always create a new workflow, no artifacts there.

So I guess the solution should be either

"1. always trigger the save workflow, not create new one"

or

"2. some how write command to always download artifacts from last workflow"

I don't know which one is better or is there any other solution.

To 1., I can't find any command to "trigger the same". To 2., there are more concerns, how to get the last artifact, if the last workflow errors, so on.

I also guess there be other solutions, like commit the csv to repo every day or use github api to write to gist. But if possible, I thought the solution 1 should be better.

Thank you for your help.

0

There are 0 best solutions below