2022-11-14 08:38:07 -05:00
|
|
|
name: Go generate check
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- "release/**"
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
go-generate:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-01-05 10:17:51 -05:00
|
|
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-14 08:38:07 -05:00
|
|
|
with:
|
|
|
|
path: constellation
|
2022-12-19 09:21:28 -05:00
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
2023-03-02 12:07:29 -05:00
|
|
|
token: ${{ !github.event.pull_request.head.repo.fork && secrets.CI_COMMIT_PUSH_PR || '' }}
|
2022-11-14 08:38:07 -05:00
|
|
|
|
|
|
|
- name: Setup Go
|
2022-12-14 08:55:14 -05:00
|
|
|
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
|
2022-11-14 08:38:07 -05:00
|
|
|
with:
|
2023-03-08 04:05:36 -05:00
|
|
|
go-version: "1.20.2"
|
2022-11-14 08:38:07 -05:00
|
|
|
cache: true
|
|
|
|
cache-dependency-path: constellation/go.mod
|
|
|
|
|
|
|
|
- name: Install docgen
|
|
|
|
uses: ./constellation/.github/actions/install_docgen
|
|
|
|
|
|
|
|
- name: Install stringer
|
|
|
|
shell: bash
|
2023-01-17 10:12:23 -05:00
|
|
|
run: go install golang.org/x/tools/cmd/stringer@7db99dd12661adab9ce92e9b9633b6ef90867fad # v0.5.0
|
2022-11-14 08:38:07 -05:00
|
|
|
|
|
|
|
- name: Get Go submodules
|
|
|
|
id: submods
|
|
|
|
shell: bash
|
|
|
|
working-directory: constellation
|
|
|
|
run: |
|
|
|
|
mods=$(go list -f '{{.Dir}}' -m | xargs)
|
|
|
|
echo "Found mods: $mods"
|
|
|
|
echo "submods=${mods}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
- name: Go generate check
|
2022-12-14 10:08:51 -05:00
|
|
|
id: generatecheck
|
2022-11-14 08:38:07 -05:00
|
|
|
shell: bash
|
|
|
|
working-directory: constellation
|
|
|
|
run: |
|
|
|
|
mods="${{ steps.submods.outputs.submods }}"
|
|
|
|
for mod in $mods; do
|
2023-01-18 09:22:20 -05:00
|
|
|
go generate "$mod/..."
|
2022-11-14 08:38:07 -05:00
|
|
|
done
|
|
|
|
git diff --exit-code
|
2022-12-14 10:08:51 -05:00
|
|
|
|
|
|
|
- name: Push changes on renovate branch
|
2022-12-23 05:16:26 -05:00
|
|
|
if: |
|
|
|
|
failure() &&
|
|
|
|
(steps.generatecheck.conclusion == 'failure')
|
|
|
|
&& startsWith(github.head_ref, 'renovate/') &&
|
|
|
|
!github.event.pull_request.head.repo.fork
|
2022-12-14 10:08:51 -05:00
|
|
|
shell: bash
|
|
|
|
working-directory: constellation
|
|
|
|
run: |
|
|
|
|
diff_dirs=$(git diff --name-only)
|
|
|
|
if [[ "${diff_dirs}" == "internal/versions/versions.go" ]]; then
|
|
|
|
echo "internal/versions/versions.go is the only changed file, so we can push the changes."
|
2023-02-20 09:33:59 -05:00
|
|
|
git config --global user.name "edgelessci"
|
|
|
|
git config --global user.email "edgelessci@users.noreply.github.com"
|
2023-01-12 12:13:25 -05:00
|
|
|
git commit -am "deps: update versions.go"
|
2022-12-14 10:08:51 -05:00
|
|
|
git push
|
|
|
|
fi
|