77 workflow_dispatch :
88
99jobs :
10- build-and-publish :
11- name : Build and publish
10+ build :
11+ name : Build and push the generated code
1212 runs-on : ubuntu-latest
1313 # here we reuse an image that is maintained for the CS3APIs bindings, which contains the necessary tools (buf)
1414 # see https://github.com/cs3org/cs3apis-build/blob/master/Dockerfile
2727 chmod 400 /root/.ssh/known_hosts
2828 ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null
2929 - name : build-and-push
30- env :
31- GH_TOKEN : ${{ github.token }}
30+ id : build
31+ outputs :
32+ pushbuf : ${{ steps.build.outputs.pushbuf }}
3233 run : |
3334 set -x
3435 buf generate
@@ -39,19 +40,28 @@ jobs:
3940 git config user.name "cernbox-bot"
4041 cp ../grpc-proto/build/*.go .
4142 git add .
42- todo =1
43- git commit -m "Synced to https://github.com/cern-eos/grpc-proto/tree/${{ github.sha }}" || todo =0
44- if [ $todo -eq 1 ]; then
43+ push =1
44+ git commit -m "Synced to https://github.com/cern-eos/grpc-proto/tree/${{ github.sha }}" || push =0
45+ if [ $push -eq 1 ]; then
4546 git push origin main
4647 else
4748 echo "The committed changes (if any) did not update the protobufs, nothing more to do"
48- gh run cancel ${{ github.run_id }}
49- gh run watch ${{ github.run_id }}
5049 fi
50+ echo "pushbuf=$push" >> $GITHUB_ENV
51+ - name : Set pushbuf output
52+ run : echo "::set-output name=pushbuf::$push"
53+ publish :
54+ name : Setup buf to push artifacts
55+ runs-on : ubuntu-latest
56+ container : cs3org/cs3apis-build:master
57+ needs : build
58+ if : needs.build.outputs.pushbuf == '1' # skip all this when nothing to do
59+ steps :
5160 - name : setup-buf
5261 uses : bufbuild/buf-setup-action@v1
5362 - name : push-buf
5463 uses : bufbuild/buf-push-action@v1
5564 with :
5665 buf_token : ${{ secrets.BUF_TOKEN }}
5766 draft : ${{ github.ref_name != 'master'}}
67+
0 commit comments