Skip to content

Update fork-maintenance.yml #25

Update fork-maintenance.yml

Update fork-maintenance.yml #25

name: Dynamic Schedule Workflow
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *' # Runs every hour
jobs:
schedule_job:
runs-on: ubuntu-latest
env:
SCHEDULE_CONFIG: ${{ secrets.SCHEDULE_CONFIG }} # Secret storing the schedule JSON
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read schedule configuration
id: read_config
run: |
echo "${{ env.SCHEDULE_CONFIG }}" > schedule.json
- name: Parse and use schedule data
id: parse_schedule
run: |
cat <<EOF > schedule.json
{

Check failure on line 27 in .github/workflows/dynamic-scheduled-fork-maintenance.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/dynamic-scheduled-fork-maintenance.yml

Invalid workflow file

You have an error in your yaml syntax on line 27
"events": [
{
"name": "weekly_backup",
"upstream_main_branch": "main",
"upstream_release_branch": "v4.43-release",
"downstream_testing_branch": "rocm6.3_testing_rel4.43_testing",
"downstream_develop_branch": "develop",
"commits": [
"731f0308bb0a2796e28b68664f4ed050eab6dbfd",
"0c1b311bff616a4faf214461584a758fbab14a6f",
"5b2d4fec5abb8ffe755fe66ce0856fc066c561a6"
],
"branching_date": "2024-08-07T00:00:00Z",
"last_run": "2024-08-09T00:00:00Z"
},
{
"name": "monthly_update",
"upstream_main_branch": "main",
"upstream_release_branch": "v4.44-release",
"downstream_testing_branch": "rocm6.3_testing_rel4.44_testing",
"downstream_develop_branch": "develop",
"commits": [
"731f0308bb0a2796e28b68664f4ed050eab6dbfd",
"0c1b311bff616a4faf214461584a758fbab14a6f",
"5b2d4fec5abb8ffe755fe66ce0856fc066c561a6"
],
"branching_date": "2024-08-15T00:00:00Z",
"last_run": "2024-07-15T00:00:00Z"
}
]
}
EOF
SCHEDULE_FILE="schedule.json"
SCHEDULE=$(cat $SCHEDULE_FILE)
echo "Schedule: $SCHEDULE"
# Loop through each event in the schedule
for row in $(jq -c '.events[]' $SCHEDULE_FILE); do
NAME=$(echo $row | jq -r '.name')
LAST_RUN=$(echo $row | jq -r '.last_run')
BRANCHING_DATE=$(echo $row | jq -r '.branching_date')
# Get the current date
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
if [[ "$CURRENT_DATE" > "$BRANCHING_DATE" && "$LAST_RUN" < "$BRANCHING_DATE" ]]; then
echo "Event $NAME needs to run. Last run: $LAST_RUN, Branching date: $BRANCHING_DATE, Current date: $CURRENT_DATE"
echo "::set-output name=event::$NAME"
SCHEDULE_JSON=$(echo $row | jq -c '{upstream_main_branch, upstream_release_branch, downstream_testing_branch, downstream_develop_branch, commits}')
echo "::set-output name=schedule_json::$SCHEDULE_JSON"
break
fi
done
- name: Fork Maintenance System
if: steps.parse_schedule.outputs.event != ''
uses: Cemberk/Fork-Maintenance-System@main
with:
github_token: ${{ secrets.CRED_TOKEN }}
upstream_repo: "https://github.com/huggingface/transformers"
schedule_json: ${{ steps.parse_schedule.outputs.schedule_json }}
pr_branch_prefix: "scheduled-merge"
unit_test_command: "your-unit-test-command"
performance_test_command: "your-performance-test-command"
- name: Remove completed event from schedule
if: success() && steps.parse_schedule.outputs.event != ''
run: |
SCHEDULE_FILE=schedule.json
EVENT_NAME=${{ steps.parse_schedule.outputs.event }}
jq 'del(.events[] | select(.name == "'$EVENT_NAME'"))' $SCHEDULE_FILE > tmp.$$.json && mv tmp.$$.json $SCHEDULE_FILE
- name: Update secret with new schedule configuration
if: success() && steps.parse_schedule.outputs.event != ''
run: |
SCHEDULE_JSON=$(cat schedule.json)
gh secret set SCHEDULE_CONFIG --body "$SCHEDULE_JSON"
env:
GITHUB_TOKEN: ${{ secrets.CRED_TOKEN }}