Daily Workflow #329
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
name: Daily Workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
clear-log: | |
description: 'Defines if it closes the old buildfarmer log issue and create a new one' | |
type: boolean | |
required: false | |
default: false | |
schedule: | |
# UTC timezone | |
- cron: '30 11 * * *' | |
jobs: | |
daily-workflow: | |
name: Daily Workflow | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get current date | |
run: echo "DOW=$(date +%u)" >> $GITHUB_ENV # Day of week (1-7, 1 = Monday) | |
- name: Get current buildfarmer log | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | |
echo "CURRENT_LOG=$(gh issue list -R ${{ github.repository }} -l buildfarmer-log | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Close old buildfarmer log | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ inputs.clear-log || env.DOW == '1' }} | |
run: | | |
gh issue close -R ${{ github.repository }} $CURRENT_LOG | |
echo "OLD_LOG=$CURRENT_LOG" >> $GITHUB_ENV | |
- name: Open new buildfarmer log | |
if: ${{ inputs.clear-log || env.DOW == '1' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
current_date=$(date +%Y/%m/%d) | |
issue_title="Buildfarmer log $current_date - $(date -d "$current_date +7 days" +%Y/%m/%d)" | |
issue_body="Previous log #$OLD_LOG" | |
created_issue=$(gh issue create -R ${{ github.repository }} -t "$issue_title" -b "$issue_body" -l buildfarmer-log) | |
echo "CURRENT_LOG=$created_issue" >> $GITHUB_ENV | |
echo "Issue created $created_issue" | |
- uses: actions/checkout@v3 | |
- name: Set up Ruby 3.2 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2' | |
- name: Generate today's report | |
run: | | |
cd database/scripts | |
echo "REPORT_NAME=$(./generate_report.rb)" >> $GITHUB_ENV | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.REPORT_NAME }} | |
path: database/scripts/${{ env.REPORT_NAME }} | |
- name: Save report into markdown format | |
run: | | |
cd database/scripts | |
echo "# $(date '+%b %d')" > formatted_report.md | |
./format_report.rb ${{ env.REPORT_NAME }} >> formatted_report.md | |
- name: Upload report to weekly buildfarmer log | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh issue comment -R ${{ github.repository }} $CURRENT_LOG -F database/scripts/formatted_report.md |