MySQL and Golang Workflow #186
This file contains hidden or 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: MySQL and Golang Workflow | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * 0" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v4 | |
| with: | |
| go-version: '>=1.21.5' | |
| - run: go version | |
| - name: reset outputs | |
| run: | | |
| if ls "$dir"/*.txt 1> /dev/null 2>&1; then | |
| echo "There are .txt files in $dir." | |
| git rm outputs/*.txt | |
| fi | |
| - name: Build and run Golang code | |
| run: | | |
| go build -o myapp | |
| ./myapp | |
| - name: Commit and push changes | |
| run: | | |
| if ! git diff --quiet; then | |
| # If not clean, add all changes and commit | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| git add outputs/* | |
| git commit -m "✔️ $(date '+%Y-%m-%d %H:%M:%S') Created" | |
| git push origin HEAD:master | |
| echo "Changes committed successfully." | |
| else | |
| echo "No Changes" | |
| fi | |