diff --git a/.github/workflows/oldest_quarter.yml b/.github/workflows/oldest_quarter.yml new file mode 100644 index 000000000..7ff4f15ea --- /dev/null +++ b/.github/workflows/oldest_quarter.yml @@ -0,0 +1,29 @@ +name: Oldest Quarter Workflow +on: + workflow_dispatch: + schedule: + - cron: '0 9 * */3 *' +jobs: + oldest-quarter: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: main + - name: Install requirements + run: pip install -r tools/requirements.txt + - name: Run maintenance for outdates files + run: python3 tools/maintenance.py -r 1 + - name: Run find-oldest-quarter.sh + run: tools/find-oldest-quarter.sh + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: oldest-quarter + path: oldest-quarter.csv + - name: Next step + run: | + echo "The content list has been uploaded as an artifact. + Review the content for this quarter by downloading it" \ No newline at end of file diff --git a/.github/workflows/stats-pr.yml b/.github/workflows/stats-pr.yml index 01f354646..f414b2eae 100644 --- a/.github/workflows/stats-pr.yml +++ b/.github/workflows/stats-pr.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-24.04-arm steps: - name: Checkout main branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: main - name: Download stats report as artifact @@ -21,18 +21,30 @@ jobs: # Run ID of the workflow that uploaded the artifact run-id: ${{ github.event.workflow_run.id }} github-token: ${{ github.token }} + - name: Check if artifact exists + run: | + if [ ! -d stats_current_test_info ]; then + echo "No stats artifact found" + echo "ARTIFACT_EXIST=false" >> "$GITHUB_ENV" + else + echo "Stats artifact found" + echo "ARTIFACT_EXIST=true" >> "$GITHUB_ENV" + fi - name: Move stats file # Unpack the artifact and move the stats file to the correct location + if: env.ARTIFACT_EXIST == 'true' run: | mv stats_current_test_info/stats_current_test_info.yml data/stats_current_test_info.yml rm -rf stats_current_test_info - name: Set workflow link as environment variable + if: env.ARTIFACT_EXIST == 'true' run: echo "WORKFLOW_URL=${{ github.event.workflow_run.workflow_url }}" >> $GITHUB_ENV - name: Echo Workflow URL + if: env.ARTIFACT_EXIST == 'true' run: echo $WORKFLOW_URL - name: Create Pull Request uses: peter-evans/create-pull-request@v6 - if: success() + if: env.ARTIFACT_EXIST == 'true' && success() with: commit-message: Update stats_current_test_info.yml title: Update stats_current_test_info.yml diff --git a/tools/report.py b/tools/report.py index 3a525653d..aa7e18825 100644 --- a/tools/report.py +++ b/tools/report.py @@ -25,7 +25,12 @@ """ def get_latest_updated(directory, is_lp, item): article_path = directory if is_lp else f"{directory}/{item}" - date = subprocess.run(["git", "log", "-1" ,"--format=%cs", str(article_path)], stdout=subprocess.PIPE) + process = subprocess.run(["git", "log", "-2" ,"--format=%cs", str(article_path)], stdout=subprocess.PIPE) + dates = process.stdout.decode("utf-8").split("\n") + if dates[0] == "2025-01-09": + date = dates[1] + else: + date = dates[0] return date """ @@ -53,7 +58,6 @@ def content_parser(directory, period): date = get_latest_updated(directory, is_lp, item) # strip out '\n' and decode byte to string - date = date.stdout.rstrip().decode("utf-8") logging.debug(f"Last updated: {date}") author = "None" for directory_list in open(directory +"/" + item):