Generate Code and Commit #21
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: Generate Code and Commit | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # Runs daily at midnight UTC | |
jobs: | |
generate-code: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5 | |
with: | |
go-version: "1.23" | |
- name: Run go generate | |
run: go generate ./... | |
env: | |
GITHUB_API_TOKEN: ${{ secrets.GH_API_TOKEN }} | |
- name: Check for changes | |
id: check_for_changes | |
run: | | |
if git diff --exit-code; then | |
echo "No changes detected." | |
echo "changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected." | |
echo "changes=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit changes | |
if: steps.check_for_changes.outputs.changes == 'true' | |
run: | | |
git config user.name "svccicd" | |
git config user.email "[email protected]" | |
git add . | |
DATE=$(date '+%Y-%m-%d') | |
git commit -m "fix(devicetype-library): updating data from remote repo <$DATE>." | |
git push -f origin main |