Merge pull request #107 from overmindtech/renovate/bufbuild-npm #186
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: Update Libraries | |
on: push | |
jobs: | |
golang: | |
name: Update Libraries | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Required for `git describe` | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.x | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
cache: npm | |
- name: Install additional go tooling | |
run: | | |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | |
go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest | |
- name: Install additional js tooling | |
run: | | |
npm ci | |
- uses: oleksiyrudenko/gha-git-credentials@v2-latest | |
with: | |
global: true | |
name: "Engineering" | |
actor: "overmindtech" | |
token: "${{ secrets.SDP_PUSH_TOKEN }}" | |
- name: Rebuilding generation targets (sdp-go, sdp-js) | |
run: | | |
set -x | |
# remove the symlinks | |
rm -f gen/sdp-go gen/sdp-js | |
# replace them with full checkouts | |
git clone https://${GIT_USER}@github.com/overmindtech/sdp-go.git gen/sdp-go | |
git clone https://${GIT_USER}@github.com/overmindtech/sdp-js.git gen/sdp-js | |
# remove previously generated files | |
rm -Rf gen/sdp-go/*.pb.go gen/sdp-go/sdpconnect/*.connect.go | |
rm -Rf gen/sdp-js/src/__generated__/ | |
# generate the code | |
npx buf generate | |
SDP_DESCRIBE="$(git describe)" | |
# add and commit the results | |
for i in sdp-go sdp-js; do | |
( | |
cd gen/$i | |
git pull | |
git add -A | |
git commit -m "Updated to SDP ${SDP_DESCRIBE}" || exit 0 | |
# show the results | |
echo "::group::$i changes" | |
git show | |
echo "::endgroup::" | |
) | |
done | |
- name: Push to repos | |
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | |
run: | | |
set -x | |
for i in sdp-go sdp-js; do | |
( | |
cd gen/$i | |
git push | |
) | |
done |