File tree Expand file tree Collapse file tree 3 files changed +79
-1
lines changed
Expand file tree Collapse file tree 3 files changed +79
-1
lines changed Original file line number Diff line number Diff line change 2424 required : false
2525 default : false
2626 type : boolean
27+ reset :
28+ required : false
29+ default : true
30+ type : boolean
31+ rebase :
32+ required : false
33+ default : true
34+ type : boolean
2735 secrets :
2836 UCI_GITHUB_TOKEN :
2937 required : true
@@ -126,6 +134,8 @@ jobs:
126134 env :
127135 BRANCH : ${{ inputs.branch }}
128136 DEFAULT_BRANCH : ${{ fromJSON(steps.github.outputs.json).default_branch }}
137+ RESET : ${{ inputs.reset }}
138+ REBASE : ${{ inputs.rebase }}
129139 # If the branch already exists, check it out; otherwise, create it.
130140 # Then, try rebasing the uci/* branch onto the default branch.
131141 # If that fails, reset the uci/* branch to the default branch.
@@ -135,7 +145,13 @@ jobs:
135145 git checkout "$BRANCH" || git checkout -B "$BRANCH"
136146 # Registering SHA before rebase to push even if only the default branch moved
137147 git rev-parse HEAD | xargs -I{} echo "sha={}" | tee -a $GITHUB_OUTPUT
138- git rebase "$DEFAULT_BRANCH" || (git rebase --abort && git reset --hard "$DEFAULT_BRANCH")
148+ if [[ "$REBASE" == 'true' && "$RESET" == 'true' ]]; then
149+ git rebase "$DEFAULT_BRANCH" || (git rebase --abort && git reset --hard "$DEFAULT_BRANCH")
150+ elif [[ "$REBASE" == 'true' ]]; then
151+ git rebase "$DEFAULT_BRANCH" || git rebase --abort
152+ elif [[ "$RESET" == 'true' ]]; then
153+ git reset --hard "$DEFAULT_BRANCH"
154+ fi
139155 - name : Configure global git user
140156 run : |
141157 git config --global user.name web3-bot
Original file line number Diff line number Diff line change 2424 description : " Whether to run in dry run mode"
2525 required : false
2626 default : ' false'
27+ reset :
28+ description : " Whether to allow resetting the branch"
29+ required : false
30+ default : ' true'
31+ rebase :
32+ description : " Whether to allow rebasing the branch"
33+ required : false
34+ default : ' true'
35+
2736
2837jobs :
2938 update-go :
3645 defaults : ${{ github.event.inputs.defaults }}
3746 override : ${{ github.event.inputs.override }}
3847 dry-run : ${{ github.event.inputs.dry-run == 'true' }}
48+ reset : ${{ github.event.inputs.reset == 'true' }}
49+ rebase : ${{ github.event.inputs.rebase == 'true' }}
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail -o nounset
4+
5+ # If ACTIONS_RUNNER_DEBUG or ACTIONS_STEP_DEBUG is set to true, print all commands
6+ if [[ " ${ACTIONS_RUNNER_DEBUG:- } " == " true" || " ${ACTIONS_STEP_DEBUG:- } " == " true" ]]; then
7+ set -x
8+ fi
9+
10+ language=" $( jq -r ' .github.languages | map(select(. == "Go")) | .[0]' <<< " $CONTEXT" ) "
11+
12+ if [[ " $language " != " Go" ]]; then
13+ echo " Not a Go project. Skipping."
14+ exit 0
15+ fi
16+
17+ expected=" $( jq -r ' .config.versions.go' <<< " $CONTEXT" ) "
18+
19+ tmp=" $( mktemp -d) "
20+ pushd " $tmp " > /dev/null
21+ curl -sSfL " https://golang.org/dl/go$expected .linux-amd64.tar.gz" | tar -xz
22+ export PATH=" $tmp /go/bin:$PATH "
23+ export GOPATH=$tmp /go
24+ popd > /dev/null
25+
26+ echo " Go version: $( go version) "
27+ echo " Go path: $( go env GOPATH) "
28+
29+ pushd " $TARGET " > /dev/null
30+
31+ while read file; do
32+ pushd " $( dirname " $file " ) " > /dev/null
33+
34+ if go list -m -json all | jq -se ' map(select(.Path == "github.com/libp2p/go-libp2p")) | length != 0' > /dev/null; then
35+ go get -u github.com/libp2p/go-libp2p
36+ go mod tidy
37+ elif go list -m -json all | jq -se ' map(select(.Path == "github.com/quic-go/quic-go")) | length != 0' > /dev/null; then
38+ go get -u github.com/quic-go/quic-go
39+ go mod tidy
40+ fi
41+
42+ git add .
43+
44+ if ! git diff-index --quiet HEAD; then
45+ git commit -m " chore: bump go-libp2p and/or quic-go to latest version"
46+ fi
47+
48+ popd > /dev/null
49+ done <<< " $(git ls-tree --full-tree --name-only -r HEAD | grep 'go\.mod$')"
50+
51+ popd > /dev/null
You can’t perform that action at this time.
0 commit comments