go-run-schedule #652
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-run-schedule" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 7 * * *" | |
jobs: | |
go-run-schedule: | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Setup Git Project" | |
uses: "actions/checkout@v3" | |
- name: "Setup Go Env" | |
uses: "actions/setup-go@v4" | |
with: | |
cache: true | |
go-version: "1.19.2" | |
- name: "Collecting FED Data" | |
env: | |
FED_API_KEY: '${{ secrets.FED_API_KEY }}' | |
run: | | |
go run main.go | |
- name: "Ensure Private Key" | |
env: | |
BOT_SSH_KEY: '${{ secrets.BOT_SSH_KEY }}' | |
run: | | |
echo "$BOT_SSH_KEY" > /tmp/id_ed25519 | |
- name: "Setup SSH Agent" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
ssh-agent -a ${SSH_AUTH_SOCK} > /dev/null | |
chmod 0600 /tmp/id_ed25519 | |
ssh-add /tmp/id_ed25519 | |
- name: "Setup Git Config" | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git remote set-url origin [email protected]:${GITHUB_REPOSITORY}.git | |
- name: "Commit And Push" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
if [[ $(git status --porcelain) ]]; then | |
git add data/*.json | |
git commit -m "update fed data" | |
git push | |
fi | |
- name: "Cleanup Build Container" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
ssh-add -D | |
rm -Rf * |