1212 name : Check go.mod Dependencies
1313 runs-on : ubuntu-latest
1414 if : ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }}
15+ outputs :
16+ tag : ${{ steps.get-tag-step.outputs.tag }}
1517 steps :
1618 - name : Get tag
1719 run : |
@@ -34,48 +36,38 @@ jobs:
3436
3537 create-release :
3638 name : Create Release
37- runs-on : ubuntu-latest
3839 needs : check-gomod-deps
40+ runs-on : ubuntu-latest
3941 if : ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }}
42+ outputs :
43+ tag : ${{ needs.check-gomod-deps.outputs.tag }}
4044 steps :
4145 - name : Checkout repository
4246 uses : actions/checkout@v2
4347 with :
4448 ref : refs/heads/${{github.event.workflow_run.head_branch}}
4549
46- - name : Get tag
47- run : |
48- branch=${{github.event.workflow_run.head_branch}}
49- echo '::set-output name=tag::'${branch#release/}
50- id : get-tag-step
51-
52- - name : Push tag ${{ steps.get-tag-step.outputs.tag }}
50+ - name : Push tag ${{ needs.check-gomod-deps.outputs.tag }}
5351 run : |
5452 git status
55- git tag ${{ steps.get-tag-step .outputs.tag }}
56- git push origin ${{ steps.get-tag-step .outputs.tag }} -f
53+ git tag ${{ needs.check-gomod-deps .outputs.tag }}
54+ git push origin ${{ needs.check-gomod-deps .outputs.tag }} -f
5755
58- - name : Create release ${{ steps.get-tag-step .outputs.tag }}
56+ - name : Create release ${{ needs.check-gomod-deps .outputs.tag }}
5957 uses : actions/create-release@v1
6058 env :
6159 GITHUB_TOKEN : ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
6260 with :
63- tag_name : refs/tags/${{ steps.get-tag-step .outputs.tag }}
64- release_name : ${{ steps.get-tag-step .outputs.tag }}
61+ tag_name : refs/tags/${{ needs.check-gomod-deps .outputs.tag }}
62+ release_name : ${{ needs.check-gomod-deps .outputs.tag }}
6563 draft : false
6664 prerelease : false
6765
6866 docker :
69- runs-on : ubuntu-latest
7067 needs : check-gomod-deps
68+ runs-on : ubuntu-latest
7169 if : ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }}
7270 steps :
73- - name : Get tag
74- run : |
75- branch=${{github.event.workflow_run.head_branch}}
76- echo '::set-output name=tag::'${branch#release/}
77- id : get-tag-step
78-
7971 - name : " Checkout"
8072 uses : actions/checkout@v2
8173 with :
9789 file : Dockerfile
9890 context : .
9991 push : true
100- tags : " ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.get-tag-step.outputs.tag }}"
92+ tags : " ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ needs.check-gomod-deps.outputs.tag }}"
93+
94+ check-branch :
95+ name : Check release branch in deployments-k8s
96+ needs : create-release
97+ runs-on : ubuntu-latest
98+ if : ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_branch, 'release/') }}
99+ outputs :
100+ tag : ${{ needs.create-release.outputs.tag }}
101+ steps :
102+ - name : Checkout networkservicemesh/deployments-k8s
103+ uses : actions/checkout@v2
104+ with :
105+ path : networkservicemesh/deployments-k8s
106+ repository : networkservicemesh/deployments-k8s
107+ token : ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
108+
109+ - name : check-release-branch
110+ working-directory : networkservicemesh/deployments-k8s
111+ run : |
112+ echo Starting to check release branch in deployments-k8s repository
113+ branch=release/${{ needs.create-release.outputs.tag }}
114+ echo branch to be checked - ${branch}
115+
116+ if ! [ -z "$(git ls-remote --heads origin ${branch})" ]; then
117+ echo Branch ${branch} is already presented in deployments-k8s repository
118+ exit 0;
119+ fi
120+
121+ echo Branch ${branch} is not presented in repository
122+ echo Starting to create ${branch} branch in deployments-k8s repository
123+
124+ git config --global user.email "nsmbot@networkservicmesh.io"
125+ git config --global user.name "NSMBot"
126+ git checkout -b ${branch}
127+ git push -u origin ${branch} || exit 0;
128+
129+ update-deployments-k8s :
130+ name : Update deployments-k8s
131+ needs : check-branch
132+ runs-on : ubuntu-latest
133+ if : ${{ github.repository != 'networkservicemesh/cmd-template' }}
134+ steps :
135+ - name : Checkout ${{ github.repository }}
136+ uses : actions/checkout@v2
137+ with :
138+ path : ${{ github.repository }}
139+ repository : ${{ github.repository }}
140+
141+ - name : Create commit message
142+ working-directory : ${{ github.repository }}
143+ run : |
144+ echo "Update docker images to the latest tag ${{ needs.check-branch.outputs.tag }}" >> /tmp/commit-message
145+ echo "" >> /tmp/commit-message
146+ echo "Commit Message:"
147+ cat /tmp/commit-message
148+
149+ - name : Checkout networkservicemesh/deployments-k8s
150+ uses : actions/checkout@v2
151+ with :
152+ path : networkservicemesh/deployments-k8s
153+ repository : networkservicemesh/deployments-k8s
154+ token : ${{ secrets.NSM_BOT_GITHUB_TOKEN }}
155+ ref : release/${{ needs.check-branch.outputs.tag }}
156+
157+ - name : Find and Replace ci/${{ github.repository }} version
158+ uses : jacobtomlinson/gha-find-replace@master
159+ with :
160+ find : " ci/${{ github.event.repository.name }}:.*\n "
161+ replace : " ${{ github.event.repository.name }}:${{ needs.check-branch.outputs.tag }}\n "
162+
163+ - name : Push update to the deployments-k8s
164+ working-directory : networkservicemesh/deployments-k8s
165+ run : |
166+ echo Starting to update repositotry deployments-k8s
167+ git add -- .
168+ if ! [ -n "$(git diff --cached --exit-code)" ]; then
169+ echo Repository already up to date
170+ exit 0;
171+ fi
172+
173+ branch=release/${{ github.repository }}/${{ needs.check-branch.outputs.tag }}
174+ git config --global user.email "nsmbot@networkservicmesh.io"
175+ git config --global user.name "NSMBot"
176+ git commit -s -F /tmp/commit-message
177+ git checkout -b ${branch}
178+ git push -f origin ${branch}
0 commit comments