From fee1aad3a2d7e2bdfa7bce5738d26dfc48e282d8 Mon Sep 17 00:00:00 2001 From: StakeNode <163791420+0xstakenode@users.noreply.github.com> Date: Sun, 24 Mar 2024 11:51:49 +0800 Subject: [PATCH] Initial commit --- .github/workflows/master.yml | 51 +++++++++++++++++++++++++++++ README.md | 63 ++++++++++++++++++++++++++++++++++++ TIMESTAMP.txt | 1 + 3 files changed, 115 insertions(+) create mode 100644 .github/workflows/master.yml create mode 100644 README.md create mode 100644 TIMESTAMP.txt diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..796e615 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,51 @@ +name: Automated Commit + +on: + push: + branches: [master] # Ensures the workflow triggers on pushes to master + + schedule: + - cron: '0 */12 * * *' # Executes every 12 hours + + workflow_dispatch: # Allows manual triggering from the GitHub UI + +permissions: + contents: write # Grants permissions to write to the repo + +jobs: + update_commit: + runs-on: ubuntu-latest # Specifies the runner + + steps: + - name: Setup Debug Information + run: echo "::debug::Triggered by ref = ${{github.ref}}" + + - name: Checkout Code + uses: actions/checkout@v3 # Latest version for optimized performance + with: + persist-credentials: true # Ensures credentials are available for subsequent steps + fetch-depth: 0 # Fetches all history for all branches and tags + + - name: Update Timestamp File + run: | + current_time=$(date '+%Y-%m-%d %H:%M:%S') + echo "Updated on $current_time" > TIMESTAMP.txt + + - name: Setup Git Configuration + run: | + git config user.email "rxmxdhxni@gmail.com" + git config user.name "dante4rt" + + - name: Prepare Commit + run: | + commit_messages=("Update: ⏰" "Refresh: 🔄" "Renew: 🌟" "Revise: 📝" "Amend: 🛠" "Adjust: 🔧" "Change: 📈" "Modify: 🖊" "Transform: 🌀" "Revamp: 🌈") + random_msg=${commit_messages[$RANDOM % ${#commit_messages[@]}]} + + git add TIMESTAMP.txt + git commit -m "$random_msg - $current_time" || echo "No changes to commit." + + - name: GitHub Push + uses: ad-m/github-push-action@v0.6.0 + with: + directory: '.' + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..c8c52fd --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Automated-Commit + +This repository contains a GitHub Actions workflow that automatically updates a file named `TIMESTAMP.txt` with the current date and time every 12 hours. This README provides a detailed overview of how the workflow operates and guides you through customizing and using it, especially if you're new to GitHub or GitHub Actions. + +## Overview + +The `Automated-Commit` workflow demonstrates the capabilities of GitHub Actions for automating routine tasks within a repository. Specifically, this workflow: + +- Checks out the latest code from the `master` branch. +- Updates the `TIMESTAMP.txt` file with the current date and time. +- Commits the change to the repository if any modifications are detected. +- Pushes the changes back to the `master` branch. + +## Workflow Structure + +The workflow is defined in the `.github/workflows/master.yml` file and includes: + +- **Triggers**: Configured to run every 12 hours and can be manually triggered via the GitHub UI with the `workflow_dispatch` event. +- **Jobs and Steps**: Contains a job `update_commit` that runs on the latest Ubuntu runner, performing tasks such as setting up Git, updating `TIMESTAMP.txt`, and committing and pushing changes. +- **Permissions**: Granted write permissions to the repository contents. + +## Using This Workflow + +### Creating Your Own Version + +To create your own version of this repository and workflow: + +1. Click the "Use this template" button on the GitHub repository page. +2. Choose a name for your new repository and select "Create repository from template". +3. Clone your new repository to make further customizations locally. + +### Customizing the Workflow + +Before using the workflow, you'll need to customize it with your GitHub user email and name: + +1. Navigate to the `.github/workflows/master.yml` file in your repository. +2. Edit the file, replacing `"rxmxdhxni@gmail.com"` with your email and `"dante4rt"` with your GitHub username in the `Setup Git Configuration` step. +3. Commit your changes. + +### Viewing Workflow Runs + +To view the history of workflow runs: + +1. Navigate to the `Actions` tab of your repository. +2. Select the `Automated-Commit` workflow to see details of each run. + +### Manually Triggering the Workflow + +You can manually trigger the workflow: + +1. Go to the `Actions` tab of your repository. +2. Select the `Automated-Commit` workflow. +3. Click `Run workflow`, select `master`, and click `Run workflow` again. + +## Contributing + +Contributions are welcome! Feel free to fork the repository, make your changes, and submit a pull request. + +## Support + +For issues or questions, please file an issue in the `Issues` section of the repository. + +Thank you for exploring the Automated-Commit workflow! diff --git a/TIMESTAMP.txt b/TIMESTAMP.txt new file mode 100644 index 0000000..b660445 --- /dev/null +++ b/TIMESTAMP.txt @@ -0,0 +1 @@ +Updated on 2024-03-24 00:54:19