Auto generate sources #295
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: "Auto generate sources" | |
on: | |
schedule: | |
- cron: '0 7 * * *' | |
workflow_dispatch: | |
jobs: | |
autogen: | |
name: Auto generate sources | |
runs-on: 'ubuntu-latest' | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Needed for "git describe" | |
- name: Checkout GoLang repository | |
run: | | |
git clone --progress --no-checkout https://github.com/golang/go.git ${{ runner.temp }}/go | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
check-latest: true | |
go-version: "stable" | |
- name: Generate | |
run: | | |
go generate ./... | |
env: | |
GORE_GO_REPO: ${{ runner.temp }}/go | |
- name: Commit changes if any and push a new tag | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
# If there are changes to the generated files, commit them | |
if [[ -n $(git status --porcelain) ]]; then | |
git add . | |
git commit -m "chore: update generated files" | |
git push | |
# Increment the patch version and create a new tag | |
git tag $(git describe --tags --abbrev=0 | awk -F. -v OFS=. '{$NF += 1 ; print}') | |
git push --tags | |
else | |
echo "::notice::Generated files are up to date." | |
fi | |