Skip to content

Commit e14b961

Browse files
authored
Merge pull request #14980 from saheerb/master
github action fix for uppercase repository owner
2 parents 3244f97 + 7698035 commit e14b961

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

.github/workflows/docker_management.branch.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
echo ${{ steps.extract_branch.outputs.branch }}-${date} > build_info/prod_tag_dated
5959
echo ${{ steps.extract_branch.outputs.branch }}-latest > build_info/prod_tag_latest
6060
echo ${{ steps.extract_branch.outputs.branch }} > build_info/mbed_os_version
61+
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' > build_info/repository_owner
6162
6263
-
6364
name: Archive information
@@ -95,6 +96,8 @@ jobs:
9596
value=`cat prod_tag_latest`
9697
echo "::set-output name=DOCKER_PROD_TAG_LATEST::$value"
9798
echo "PROD TAG is $value"
99+
value=`cat repository_owner`
100+
echo "::set-output name=REPO_OWNER::$value"
98101
99102
-
100103
name: Set up Docker Buildx
@@ -125,7 +128,7 @@ jobs:
125128
platforms: linux/amd64,linux/arm64
126129
push: true
127130
file: ./docker_images/mbed-os-env/Dockerfile
128-
tags: ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }}
131+
tags: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }}
129132

130133
test-container:
131134
runs-on: ubuntu-latest
@@ -156,6 +159,8 @@ jobs:
156159
echo "::set-output name=DOCKER_PROD_TAG_LATEST::$value"
157160
value=`cat mbed_os_version`
158161
echo "::set-output name=MBED_OS_VERSION::$value"
162+
value=`cat repository_owner`
163+
echo "::set-output name=REPO_OWNER::$value"
159164
160165
-
161166
name: Checkout
@@ -165,7 +170,7 @@ jobs:
165170
name: Find DEV DOCKER DIGEST
166171
id: docker_info_dev
167172
run: |
168-
DIGEST=$(python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} get-digest -r mbed-os-env-tmp -t ${{ steps.build_info.outputs.DOCKER_DEV_TAG }} -p ${{ matrix.platform }} )
173+
DIGEST=$(python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ steps.build_info.outputs.REPO_OWNER }} -p ${{ secrets.GITHUB_TOKEN }} get-digest -r mbed-os-env-tmp -t ${{ steps.build_info.outputs.DOCKER_DEV_TAG }} -p ${{ matrix.platform }} )
169174
echo "::set-output name=DIGEST::$DIGEST"
170175
echo "Docker DIGEST: $DIGEST"
171176
@@ -191,7 +196,7 @@ jobs:
191196
password: ${{ secrets.GITHUB_TOKEN }}
192197
registry: ghcr.io
193198
options: -v ${{ github.workspace }}:/work -w=/work
194-
image: ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp@${{ steps.docker_info_dev.outputs.DIGEST }}
199+
image: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp@${{ steps.docker_info_dev.outputs.DIGEST }}
195200
shell: bash
196201

197202
run: |
@@ -229,9 +234,11 @@ jobs:
229234
echo "::set-output name=DOCKER_PROD_TAG_DATED::$value"
230235
value=`cat prod_tag_latest`
231236
echo "::set-output name=DOCKER_PROD_TAG_LATEST::$value"
237+
value=`cat repository_owner`
238+
echo "::set-output name=REPO_OWNER::$value"
232239
233240
-
234241
name: copy dev tag to prod
235242
run: |
236-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_LATEST }}
237-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_DATED }}
243+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_LATEST }}
244+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_DATED }}

.github/workflows/docker_management.prune.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
# deletion if only one image exists or if DOCKER_MANAGEMENT_TOKEN is not
2323
# setup. This shouldn't create any alarm as temporary image deletion is
2424
# not a critical activity.
25-
python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ github.actor }} -p ${{ secrets.DOCKER_MANAGEMENT_TOKEN }} delete-old-images -r mbed-os-env-tmp || true
25+
python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ github.repository_owner }} -p ${{ secrets.DOCKER_MANAGEMENT_TOKEN }} delete-old-images -r mbed-os-env-tmp || true

.github/workflows/docker_management.release.yml

+30-8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
echo dev-${version}-${date}-${version} > build_info/dev_tag
7373
echo ${version}-${date} > build_info/prod_tag_dated
7474
echo ${version} > build_info/mbed_os_version
75+
echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' > build_info/repository_owner
7576
7677
-
7778
name: Archive information
@@ -87,6 +88,7 @@ jobs:
8788
outputs:
8889
DEV_DIGEST: ${{ steps.docker_info_dev.outputs.DIGEST }}
8990
PROD_DIGEST: ${{ steps.docker_info_prod.outputs.DIGEST }}
91+
REPO_FILE_CHECK: ${{steps.repo_status.outcome}}
9092

9193
steps:
9294
-
@@ -111,6 +113,8 @@ jobs:
111113
echo "::set-output name=DOCKER_PROD_TAG_DATED::$value"
112114
value=`cat mbed_os_version`
113115
echo "::set-output name=MBED_OS_VERSION::$value"
116+
value=`cat repository_owner`
117+
echo "::set-output name=REPO_OWNER::$value"
114118
115119
-
116120
name: Set up Docker Buildx
@@ -134,21 +138,35 @@ jobs:
134138
with:
135139
ref: refs/tags/${{ steps.build_info.outputs.MBED_OS_VERSION }}
136140

141+
# if we are trying to build docker image for an earlier version of mbed-os, either scheduled
142+
# or manually, dockerfile will not exist. Then, skip the workflow
143+
-
144+
name: Skip the workflow if Dockerfile doesn't exist
145+
id: repo_status
146+
run: |
147+
if [ ! -f "./docker_images/mbed-os-env/Dockerfile" ]; then
148+
echo "Dockerfile doesn't in this repo."
149+
exit 1
150+
fi
151+
continue-on-error: true
152+
137153
-
138154
name: Build docker containers
155+
if: steps.repo_status.outcome == 'success'
139156
uses: docker/build-push-action@v2
140157
id: docker_build_dev
141158
with:
142159
context: .
143160
platforms: linux/amd64,linux/arm64
144161
push: true
145162
file: ./docker_images/mbed-os-env/Dockerfile
146-
tags: ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }}
163+
tags: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }}
147164

148165

149166
test-container:
150167
runs-on: ubuntu-latest
151168
needs: build-container
169+
if: needs.build-container.outputs.REPO_FILE_CHECK=='success'
152170
strategy:
153171
matrix:
154172
platform: [linux/amd64, linux/arm64]
@@ -173,6 +191,8 @@ jobs:
173191
echo "::set-output name=DOCKER_PROD_TAG_DATED::$value"
174192
value=`cat mbed_os_version`
175193
echo "::set-output name=MBED_OS_VERSION::$value"
194+
value=`cat repository_owner`
195+
echo "::set-output name=REPO_OWNER::$value"
176196
177197
# as the dev images are created only for master branch, run test against
178198
# development branch of blinky
@@ -200,7 +220,6 @@ jobs:
200220
if git rev-parse "$MBED_OS_VERSION" >/dev/null 2>&1; then
201221
EXAMPLE_VERSION=$MBED_OS_VERSION
202222
fi
203-
# echo "::set-output VERSION=MBED_OS_VERSION::$EXAMPLE_VERSION"
204223
git checkout ${EXAMPLE_VERSION}
205224
206225
-
@@ -215,7 +234,7 @@ jobs:
215234
id: docker_info
216235
run: |
217236
cd mbed-os-example-blinky/mbed-os
218-
DIGEST=$(python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} get-digest -r mbed-os-env-tmp -t ${{ steps.build_info.outputs.DOCKER_DEV_TAG }} -p ${{ matrix.platform }} )
237+
DIGEST=$(python ./.github/workflows/ci_scripts/ghcr_utils.py -u ${{ steps.build_info.outputs.REPO_OWNER }} -p ${{ secrets.GITHUB_TOKEN }} get-digest -r mbed-os-env-tmp -t ${{ steps.build_info.outputs.DOCKER_DEV_TAG }} -p ${{ matrix.platform }} )
219238
echo "::set-output name=DIGEST::$DIGEST"
220239
echo "Docker DIGEST: $DIGEST"
221240
@@ -232,7 +251,7 @@ jobs:
232251
password: ${{ secrets.GITHUB_TOKEN }}
233252
registry: ghcr.io
234253
options: -v ${{ github.workspace }}:/work -w=/work
235-
image: ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp@${{ steps.docker_info.outputs.DIGEST }}
254+
image: ghcr.io/${{ steps.build_info.outputs.REPO_OWNER }}/mbed-os-env-tmp@${{ steps.docker_info.outputs.DIGEST }}
236255
shell: bash
237256
run: |
238257
uname -m
@@ -268,18 +287,21 @@ jobs:
268287
value=`cat mbed_os_version`
269288
echo "MBED OS VERSION is $value"
270289
echo "::set-output name=MBED_OS_VERSION::$value"
290+
value=`cat repository_owner`
291+
echo "::set-output name=REPO_OWNER::$value"
271292
272293
-
273294
name: copy dev tag to prod tags
274295
run: |
275296
set -x
276297
echo ${{ needs.test-container.result }}
298+
REPO_OWNER=${{ steps.build_info.outputs.REPO_OWNER }}
277299
upto_patch_version=${{ steps.build_info.outputs.MBED_OS_VERSION }}-latest
278300
upto_min_version=${upto_patch_version%.[0-9]*}-latest
279301
upto_major_version=${upto_patch_version%.[0-9]*.[0-9]*}-latest
280-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${upto_patch_version}
281-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${upto_min_version}
282-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${upto_major_version}
302+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${REPO_OWNER}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${REPO_OWNER}/mbed-os-env:${upto_patch_version}
303+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${REPO_OWNER}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${REPO_OWNER}/mbed-os-env:${upto_min_version}
304+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${REPO_OWNER}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${REPO_OWNER}/mbed-os-env:${upto_major_version}
283305
284306
# copy to fixed tag
285-
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${{ github.repository_owner }}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_DATED }}
307+
docker run quay.io/skopeo/stable --src-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} --dest-creds=${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }} copy --all docker://ghcr.io/${REPO_OWNER}/mbed-os-env-tmp:${{ steps.build_info.outputs.DOCKER_DEV_TAG }} docker://ghcr.io/${REPO_OWNER}/mbed-os-env:${{ steps.build_info.outputs.DOCKER_PROD_TAG_DATED }}

0 commit comments

Comments
 (0)