forked from abhisheknaiidu/todoist-readme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,26 @@ | ||
name: ReadMe Worker 🚧 | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Runs every minute | ||
- cron: "* */8 * * *" | ||
|
||
jobs: | ||
build: | ||
name: Build 👔 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code ⛵️ | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
token: ${{ secrets.GH_PAT }} # make sure this secret is available in your repo settings | ||
|
||
- name: Setup new branch 🌿 | ||
run: | | ||
git config --global user.email "aldoyh@gmail.com" | ||
git config --global user.name "Mastermind ⛵️" | ||
git checkout -b todoist-stats-update | ||
- name: Update todoist stats 📊 | ||
uses: aldoyh/todoist-readme@master | ||
outputs: | ||
report: ${{ steps.todoist-stats.outputs.report }} | ||
with: | ||
TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }} | ||
|
||
- name: Check for changes in README.md 📝 | ||
id: diff-check | ||
run: | | ||
git diff --exit-code --quiet origin/main README.md || echo "difference=true" >> $GITHUB_ENV | ||
deploy: | ||
name: Deployment ⛴️ | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Commit and push changes 🚀 | ||
run: | | ||
if [[ "${{ env.difference }}" == "true" ]]; then | ||
git add . | ||
git commit -m "Update todoist stats" | ||
git fetch origin todoist-stats-update | ||
git reset --hard origin/todoist-stats-update | ||
git push --force-with-lease origin/todoist-stats-update | ||
else | ||
echo "No changes in README.md" | ||
fi | ||
echo "🚧 Diff: ${{ env.difference }}" | ||
- name: Merge into main 📦 | ||
run: | | ||
if [[ "${{ env.difference }}" == "true" ]]; then | ||
git checkout main | ||
git merge --no-ff todoist-stats-update | ||
git push origin main | ||
else | ||
echo "No changes to merge into main" | ||
fi | ||
- name: Post to Slack 💬 | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
INPUT_SLACK_MESSAGE: ${{ steps.todoist-stats.outputs.report }} | ||
INPUT_CHANNEL_ID: 'C040ZLS7P2P' | ||
name: 'Todoist Readme' | ||
author: Abhishek Naidu | ||
description: '🚧 Updates README with your Todoist stats' | ||
|
||
inputs: | ||
TODOIST_API_KEY: | ||
description: 'Your Todoist API Key' | ||
required: true | ||
|
||
USERNAME: | ||
description: 'Your GitHub username' | ||
default: ${{ github.repository_owner }} | ||
required: false | ||
|
||
PREMIUM: | ||
description: 'Premium User or Not' | ||
default: false | ||
required: false | ||
|
||
runs: | ||
using: "node12" | ||
main: "dist/index.js" | ||
|
||
branding: | ||
icon: "activity" | ||
color: "red" |