Skip to content

Commit 6cf7703

Browse files
authored
Container retention via version tagging (#3491)
* Use github action expression syntax to alias over github repository name * Tag by version instead of by timestamp * Avoid pushing untagged image to GHCR by setting provenance to false now that provenance is enabled by default as of v4 of docker/build-push-action - docker/build-push-action#781 - docker/build-push-action#778
1 parent f529e3e commit 6cf7703

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/workflows/update_ci_image.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
trigger: ${{ steps.check.outputs.trigger }}
3838
no_cache: ${{ steps.check.outputs.no_cache }}
3939
container:
40-
image: ghcr.io/ros-planning/navigation2:${{ github.ref_name }}
40+
image: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
4141
steps:
4242
- name: "Check apt updates"
4343
id: check
@@ -74,8 +74,8 @@ jobs:
7474
- name: Set build config
7575
id: config
7676
run: |
77-
timestamp=$(date --utc +%Y%m%d%H%M%S)
78-
echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT
77+
version=$(grep -oP '(?<=<version>).*?(?=</version>)' navigation2/package.xml)
78+
echo "version=${version}" >> $GITHUB_OUTPUT
7979
8080
no_cache=false
8181
if [ "${{needs.check_ci_files.outputs.no_cache}}" == 'true' ] || \
@@ -97,15 +97,16 @@ jobs:
9797
id: docker_build
9898
uses: docker/build-push-action@v4
9999
with:
100+
provenance: false
100101
pull: true
101102
push: true
102103
no-cache: ${{ steps.config.outputs.no_cache }}
103-
cache-from: type=registry,ref=ghcr.io/ros-planning/navigation2:${{ github.ref_name }}
104+
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:${{ github.ref_name }}
104105
cache-to: type=inline
105106
target: builder
106107
tags: |
107-
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}
108-
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-${{ steps.config.outputs.timestamp }}
108+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
109+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}-${{ steps.config.outputs.version }}
109110
- name: Image digest
110111
if: steps.config.outputs.trigger == 'true'
111112
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)