# ================================================================ # GitHub Actions Workflow: Update Repo Age Section (Manual Only) # ================================================================ # 🔹 This workflow updates a custom repository age section in README.md. # # ⚠️ Automatic triggers removed (manual only). # ✅ You can run it anytime from GitHub Actions UI. # ❌ The badge is no longer standalone, but part of a full markdown block. # ================================================================ name: Update Repo Age on: workflow_dispatch: jobs: update-age: runs-on: ubuntu-latest permissions: write-all steps: - name: Checkout Repository uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Get Repo Creation Date id: repo_info run: | CREATION_DATE=$(curl -s https://api.github.com/repos/madhurimarawat/Stock-Market-Prediction | jq -r '.created_at' | cut -d'T' -f1) if [ -z "$CREATION_DATE" ] || [ "$CREATION_DATE" = "null" ]; then CREATION_DATE="2024-08-08" fi echo "CREATION_DATE=$CREATION_DATE" >> $GITHUB_ENV - name: Calculate Repository Age id: calculate_age run: | START_DATE=$(date -d "$CREATION_DATE" +%s 2>/dev/null || echo "0") CURRENT_DATE=$(date +%s) if [ "$START_DATE" = "0" ]; then REPO_AGE="0Y 6M 15D" else AGE_DAYS=$(( (CURRENT_DATE - START_DATE) / 86400 )) AGE_YEARS=$(( AGE_DAYS / 365 )) AGE_MONTHS=$(( (AGE_DAYS % 365) / 30 )) AGE_REMAINING_DAYS=$(( AGE_DAYS % 30 )) REPO_AGE="${AGE_YEARS}Y ${AGE_MONTHS}M ${AGE_REMAINING_DAYS}D" fi echo "REPO_AGE=$REPO_AGE" >> $GITHUB_ENV - name: Update README.md Repo Section run: | echo '' > new_section.md echo '' >> new_section.md echo '' >> new_section.md echo ' Repository Age' >> new_section.md echo '' >> new_section.md echo '' >> new_section.md awk -v block="$(cat new_section.md)" ' BEGIN { in_block=0 } // { print block in_block=1 next } // { in_block=0; next } in_block == 0 { print } ' README.md > temp.md && mv temp.md README.md - name: Commit & Push Changes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config --global user.name "github-actions" git config --global user.email "actions@github.com" git add README.md git commit -m "🔄 Updated repo age section (manual trigger only)" || exit 0 git push origin main