Skip to content

Commit

Permalink
Update github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cho committed Feb 29, 2024
1 parent 675425d commit f494353
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/check-and-send-message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,40 @@ on:

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/configure-pages@v4
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- run: go run .

- name: Fetch and Send Message
run: |
go run . > fgi_output.txt
cat fgi_output.txt
tar -czf fgi_output.tar.gz fgi_output.txt
env:
TELEGRAM_APITOKEN: ${{ secrets.TELEGRAM_APITOKEN }}
CHATID: ${{ secrets.CHATID }}
RAPIDAPI_KEY: ${{ secrets.RAPIDAPI_KEY }}

- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: fgi_output.tar.gz

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
9 changes: 9 additions & 0 deletions fgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ func (fr FgiResult) toString() string {
fr.Fgi.OneMonthAgo.toString(),
fr.Fgi.OneYearAgo.toString())
}

func (fr FgiResult) toJson() string {
return fmt.Sprintf(`{"lastUpdate": "%s", "now": "%s", "prev": "%s", "1w ago": "%s", "1m ago": "%s", "1y ago": "%s"}`, fr.LastUpdated.HumanDate,
fr.Fgi.Now.toString(),
fr.Fgi.PreviousClose.toString(),
fr.Fgi.OneWeekAgo.toString(),
fr.Fgi.OneMonthAgo.toString(),
fr.Fgi.OneYearAgo.toString())
}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
Expand All @@ -17,6 +18,7 @@ const (
func main() {
res := getFearAndGreedIndex()
sendMesage(res)
fmt.Println(res.toJson())
}

func getFearAndGreedIndex() FgiResult {
Expand Down

0 comments on commit f494353

Please sign in to comment.