Skip to content

Auto Update and Merge Daily Activities #288

Auto Update and Merge Daily Activities

Auto Update and Merge Daily Activities #288

Workflow file for this run

name: Auto Update and Merge Daily Activities
on:
schedule:
- cron: '30 4 * * *' # Runs daily at 10:00 AM IST (4:30 AM UTC)
workflow_dispatch: # Allows manual triggering
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main # Replace with your default branch
token: ${{ secrets.GH_TOKEN }} # Use the PAT for checkout
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20 # Replace with your desired Node.js version
- name: Run update script
run: |
# Append the current date to the daily_activities.txt file
echo "Date of update (IST): $(TZ='Asia/Kolkata' date)" >> daily_activities.txt
- name: Commit changes
id: commit
run: |
git config --global user.name "hidaytrahman"
git config --global user.email "[email protected]"
git add .
git commit -m "Update daily activities file" || echo "No changes to commit"
- name: Push changes
if: steps.commit.outcome == 'success'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: auto-update-branch # Branch to push changes to
force: true # Force push to overwrite the remote branch
- name: Create Pull Request
if: steps.commit.outcome == 'success'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GH_TOKEN }}
branch: auto-update-branch
base: main # Replace with your default branch
title: "Automated update activities"
body: "Automated added activities, This PR was automatically generated by GitHub Actions."
delete-branch: true # Delete the branch after merging
# This has admin request to by pass the merge done by the flag --admin
- name: Merge Pull Request
if: steps.commit.outcome == 'success'
run: |
PR_NUMBER=$(gh pr list --state open --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "Waiting for 30 seconds before merging..."
sleep 30 # Wait for 30 seconds
gh pr merge $PR_NUMBER --merge --delete-branch --admin
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}