@@ -22,19 +22,37 @@ jobs:
2222 - name : Getting SHA from the default branch
2323 id : get-sha
2424 run : |
25- URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}"
26- DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch')
27- URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}"
28- SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"')
25+ DEFAULT_BRANCH=$(curl -s \
26+ --request GET \
27+ --url https://api.github.com/repos/${{ github.repository }} \
28+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
29+ jq -r '.default_branch')
30+
31+ SHA=$(curl -s \
32+ --request GET \
33+ --url https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH} \
34+ --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' | \
35+ jq -r '.object.sha')
36+
2937 echo ::set-output name=default_branch::${DEFAULT_BRANCH}
3038 echo ::set-output name=sha::${SHA}
3139 - name : Waiting a cache creation in the default branch
40+ if : ${{ github.ref_name != 'develop' }}
3241 run : |
33- URL_runs="https://api.github.com/repos/${{ github.repository }}/actions/workflows/cache.yml/runs"
3442 SLEEP=45
3543 NUMBER_ATTEMPTS=10
3644 while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do
37- RUN_status=$(curl -s -X GET -G ${URL_runs} | jq -r '.workflow_runs[]? | select((.head_sha == "${{ steps.get-sha.outputs.sha }}") and (.event == "push") and (.name == "Cache") and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")) | .status')
45+ RUN_status=$(curl -s \
46+ --request GET \
47+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
48+ --url https://api.github.com/repos/${{ github.repository }}/actions/workflows/cache.yml/runs | \
49+ jq -r '.workflow_runs[]? |
50+ select(
51+ (.head_sha == "${{ steps.get-sha.outputs.sha }}")
52+ and (.event == "push")
53+ and (.name == "Cache")
54+ and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")
55+ ) | .status')
3856 if [[ ${RUN_status} == "completed" ]]; then
3957 echo "The cache creation on the '${{ steps.get-sha.outputs.default_branch }}' branch has finished. Status: ${RUN_status}"
4058 break
@@ -114,10 +132,18 @@ jobs:
114132 - name : Getting SHA from the default branch
115133 id : get-sha
116134 run : |
117- URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}"
118- DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch')
119- URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}"
120- SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"')
135+ DEFAULT_BRANCH=$(curl -s \
136+ --request GET \
137+ --url https://api.github.com/repos/${{ github.repository }} \
138+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
139+ jq -r '.default_branch')
140+
141+ SHA=$(curl -s \
142+ --request GET \
143+ --url https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH} \
144+ --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' | \
145+ jq -r '.object.sha')
146+
121147 echo ::set-output name=default_branch::${DEFAULT_BRANCH}
122148 echo ::set-output name=sha::${SHA}
123149 - name : Waiting a cache creation in the default branch
@@ -126,7 +152,17 @@ jobs:
126152 SLEEP=45
127153 NUMBER_ATTEMPTS=10
128154 while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do
129- RUN_status=$(curl -s -X GET -G ${URL_runs} | jq -r '.workflow_runs[]? | select((.head_sha == "${{ steps.get-sha.outputs.sha }}") and (.event == "push") and (.name == "Cache") and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")) | .status')
155+ RUN_status=$(curl -s \
156+ --request GET \
157+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
158+ --url https://api.github.com/repos/${{ github.repository }}/actions/workflows/cache.yml/runs | \
159+ jq -r '.workflow_runs[]? |
160+ select(
161+ (.head_sha == "${{ steps.get-sha.outputs.sha }}")
162+ and (.event == "push")
163+ and (.name == "Cache")
164+ and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")
165+ ) | .status')
130166 if [[ ${RUN_status} == "completed" ]]; then
131167 echo "The cache creation on the '${{ steps.get-sha.outputs.default_branch }}' branch has finished. Status: ${RUN_status}"
132168 break
@@ -238,10 +274,19 @@ jobs:
238274 - name : Getting SHA from the default branch
239275 id : get-sha
240276 run : |
241- URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}"
242- DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch')
243- URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}"
244- SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"')
277+ DEFAULT_BRANCH=$(curl -s \
278+ --request GET \
279+ --url https://api.github.com/repos/${{ github.repository }} \
280+ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \
281+ jq -r '.default_branch')
282+
283+ SHA=$(curl -s \
284+ --request GET \
285+ --url https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH} \
286+ --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' | \
287+ jq -r '.object.sha')
288+
289+ echo ::set-output name=default_branch::${DEFAULT_BRANCH}
245290 echo ::set-output name=sha::${SHA}
246291 - name : Getting CVAT server cache from the default branch
247292 uses : actions/cache@v2
0 commit comments