Skip to content

Commit

Permalink
Adding Step Logs Github Action
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfister22 committed Jul 4, 2024
1 parent 15ae2c1 commit 060abbb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/set_logs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Set Logs

on:
schedule:
- cron: "0 12 1 * *"

jobs:
time-logs:
runs-on: ubuntu-22.04
steps:
- name: checkout_repo
uses: actions/checkout@v4
with:
ref: "master"
- name: set-logs
run: bash ./code/bash/step_logs.sh
env:
USER_EMAIL: ${{ secrets.USER_EMAIL}}
USER_NAME: ${{ secrets.USER_NAME}}
24 changes: 24 additions & 0 deletions bash/step_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
BRANCH="master"

#This was writen based on a course on LinkedIn learning with some minor adjustments.

# Save the current time into a log file
echo "Current Date:" >> ./code/bash/log.txt && date '+%Y-%m-%d' >> ./code/bash/log.txt
echo "Current Time:" >> ./code/bash/log.txt && date '+%r' >> ./code/bash/log.txt
echo "Epoch Time:" >> ./code/bash/log.txt && date '+%s' >> ./code/bash/log.txt
echo " " >> ./code/bash/log.txt

# Commit
p=$(pwd)
git config --global --add safe.directory $p

if [[ "$(git status --porcelain)" != "" ]]; then
git config --global user.name $USER_NAME
git config --global user.email $USER_EMAIL
git add code/bash/log.txt
git commit -m "Update the log"
git push origin $BRANCH
else
echo "Nothing to commit..."
fi

0 comments on commit 060abbb

Please sign in to comment.