Remove some triggers from Update dependent repositories (#173) #313
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 dependent repositories | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-dependent-repositories: | |
strategy: | |
matrix: | |
repository: [sdk] | |
name: Update ${{ matrix.repository }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v2 | |
with: | |
path: ${{ github.repository }} | |
repository: ${{ github.repository }} | |
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} | |
- name: Find merged PR | |
uses: jwalton/[email protected] | |
id: findPr | |
with: | |
sha: ${{ github.sha }} | |
github-token: ${{ github.token }} | |
- name: Create commit message | |
working-directory: ${{ github.repository }} | |
run: | | |
echo "Update go.mod and go.sum to latest version from ${{ github.repository }}@main" >> /tmp/commit-message | |
echo "PR link: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message | |
echo "" >> /tmp/commit-message | |
LOG_MSG=$(git log --date=iso --pretty='format:Commit: %h%nAuthor: %an%nDate: %ad%nMessage:%n - %B%n' -1 | sed '/^$/d;$d') | |
for((i=2;i<=18;i+=2)); do n=$(printf '%*s' $((i+2))) m=$(printf '%*s' $i) LOG_MSG=$(echo "$LOG_MSG" | tr '\n' '|' | sed "s/${m}-/${n}-/2g" | tr '|' '\n'); done | |
echo "$LOG_MSG" >> /tmp/commit-message | |
echo "Commit Message:" | |
cat /tmp/commit-message | |
- name: Checkout networkservicemesh/${{ matrix.repository }} | |
uses: actions/checkout@v2 | |
with: | |
path: networkservicemesh/${{ matrix.repository }} | |
repository: networkservicemesh/${{ matrix.repository }} | |
token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} | |
- uses: actions/setup-go@v1 | |
with: | |
go-version: 1.20.5 | |
- name: Update ${{ github.repository }} locally | |
working-directory: networkservicemesh/${{ matrix.repository }} | |
run: | | |
GOPRIVATE=github.com/networkservicemesh go get -u github.com/${{ github.repository }}@main | |
go mod tidy | |
git diff | |
- name: Push update to the ${{ matrix.repository }} | |
working-directory: networkservicemesh/${{ matrix.repository }} | |
run: | | |
echo Starting to update repositotry ${{ matrix.repository }} | |
git config --global user.email "[email protected]" | |
git config --global user.name "NSMBot" | |
git add go.mod go.sum | |
git commit -s -F /tmp/commit-message | |
git checkout -b update/${{ github.repository }} | |
git push -f origin update/${{ github.repository }} |