-
Notifications
You must be signed in to change notification settings - Fork 302
enh(ci): replace GHA cache with ghcr.io for fat container images #6109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tpo76
wants to merge
1
commit into
develop
Choose a base branch
from
MON-196408-ci-use-ghcr-io-github-containers-to-store-fat-containers-from-pipelines
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,12 +52,9 @@ on: | |
| required: true | ||
|
|
||
| jobs: | ||
| test-image-to-cache: | ||
| push-test-image-to-ghcr: | ||
| runs-on: ${{ contains(inputs.image, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Login to Registry | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | ||
| with: | ||
|
|
@@ -72,30 +69,26 @@ jobs: | |
| username: ${{ secrets.registry_username }} | ||
| password: ${{ secrets.registry_password }} | ||
|
|
||
| - name: Load image | ||
| env: | ||
| DOCKER_IMAGE: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }} | ||
| run: | | ||
| docker image prune -af | ||
| docker pull $DOCKER_IMAGE | ||
| shell: bash | ||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ github.token }} | ||
|
|
||
| - name: Save image on disk | ||
| - name: Pull image from Harbor and push to ghcr.io | ||
| env: | ||
| IMAGE_NAME: ${{ inputs.image }} | ||
| DOCKER_IMAGE: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }} | ||
| HARBOR_IMAGE: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }} | ||
| GHCR_IMAGE: ghcr.io/${{ github.repository }}/${{ inputs.image }}:${{ github.sha }}-${{ github.run_id }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test images are not yet pushed on ghcr.io |
||
| run: | | ||
| docker save -o ./$IMAGE_NAME $DOCKER_IMAGE | ||
| docker image prune -af | ||
| docker pull "${HARBOR_IMAGE}" | ||
| docker tag "${HARBOR_IMAGE}" "${GHCR_IMAGE}" | ||
| docker push "${GHCR_IMAGE}" | ||
| shell: bash | ||
|
|
||
| - name: Save image into cache | ||
| uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | ||
| with: | ||
| path: ./${{ inputs.image }} | ||
| key: ${{ inputs.image }}-${{ github.sha }}-${{ github.run_id }} | ||
|
|
||
| robot-test: | ||
| needs: [test-image-to-cache] | ||
| needs: [push-test-image-to-ghcr] | ||
| runs-on: ${{ contains(inputs.image, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} | ||
|
|
||
| strategy: | ||
|
|
@@ -110,12 +103,18 @@ jobs: | |
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Get the cached docker image for tests | ||
| uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | ||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | ||
| with: | ||
| path: ./${{ inputs.image }} | ||
| key: ${{ inputs.image }}-${{ github.sha }}-${{ github.run_id }} | ||
| fail-on-cache-miss: true | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ github.token }} | ||
|
|
||
| - name: Pull test image from ghcr.io | ||
| env: | ||
| GHCR_IMAGE: ghcr.io/${{ github.repository }}/${{ inputs.image }}:${{ github.sha }}-${{ github.run_id }} | ||
| run: docker pull "${GHCR_IMAGE}" | ||
| shell: bash | ||
|
|
||
| - name: Get the cached plugins | ||
| if: ${{ inputs.get-packages == 'True' }} | ||
|
|
@@ -132,15 +131,10 @@ jobs: | |
| key: ${{ inputs.plugins-json-cache-key }} | ||
| fail-on-cache-miss: true | ||
|
|
||
| - name: Load image | ||
| env: | ||
| IMAGE_NAME: ${{ inputs.image }} | ||
| run: docker load --input ./$IMAGE_NAME | ||
|
|
||
| - name: Install, test and remove plugin | ||
| shell: bash | ||
| env: | ||
| DOCKER_IMAGE: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ inputs.image }} | ||
| DOCKER_IMAGE: ghcr.io/${{ github.repository }}/${{ inputs.image }}:${{ github.sha }}-${{ github.run_id }} | ||
| PACKAGE_EXTENSION: ${{ inputs.package-extension }} | ||
| RUNNER_ID: ${{ matrix.index }} | ||
| SKIP_ROBOT_TESTS: ${{ inputs.skip-robot-tests }} | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to have these ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not mandatory as the docker push to ghcr.io uses ${{ github.token }}, which inherits the repository's default permissions that are currently fine.
However, we can always fine-tune by explicitly adding the permissions in the get-packaging-images section.
With this for example