go-write-to-file #4578
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
name: go-write-to-file | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '30 05,13,20 * * *' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
# Using v4 to use in-built caching | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
id: go | |
# Using modules to maintain the dependencies, and download them only when there is a cache-miss | |
- name: Get dependencies | |
if: steps.go.outputs.cache-hit != 'true' | |
run: go mod tidy | |
- name: Build | |
run: cd backend && go build -v -o main-to-file main-to-file.go | |
- run: cd backend && ./main-to-file -gh_token=${{secrets.TOKEN}} | |
- name: Get current time | |
uses: gerred/actions/current-time@master | |
id: current-time | |
- name: push to repo | |
env: | |
TIME: '${{ steps.current-time.outputs.time }}' | |
run: | | |
git pull | |
git config user.name darensin01 | |
git config user.email [email protected] | |
git add backend/data.json | |
git commit -m "$TIME: new data pushed" | |
git push |