-
Notifications
You must be signed in to change notification settings - Fork 182
ci: publish docker image for system tests #4013
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
Merged
+151
−0
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5894a60
add new job to publish CI builds to ghcr.io
MilanGarnier 8631e32
fix base image name
MilanGarnier eaf0612
Merge branch 'master' into milan.garnier/publish-ci-builds
realFlowControl 1032cd9
publish in two steps
MilanGarnier e7401c8
fix(ci): fix token lifecycle and mask github token in system tests pu…
MilanGarnier 34c8a7f
restrict CI uploads to Datadog/dd-trace-php
MilanGarnier f87131d
cleanup github token handling
MilanGarnier 495dcd1
add policy file
MilanGarnier 5adc9f1
Merge branch 'master' into milan.garnier/publish-ci-builds
MilanGarnier 1cbb010
add a workflow to delete pr images when the pr is closed
MilanGarnier 2a6c818
delete image with same tag before pushing
MilanGarnier 7c267ec
prevent two uploading jobs from running concurrently, skip uploading
MilanGarnier 59ba283
Merge branch 'master' into milan.garnier/publish-ci-builds
MilanGarnier 9b94ded
upload image with builds for all archs
MilanGarnier 4744634
Gate upload to having a PR open
MilanGarnier 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| issuer: https://gitlab.ddbuild.io | ||
|
|
||
| subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-php:ref_type:(branch|tag):ref:.*" | ||
|
|
||
| permissions: | ||
| packages: write | ||
| pull_requests: read |
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: "Delete Docker image on PR close" | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| jobs: | ||
| delete-pr-image: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| packages: write # required to delete GHCR container versions | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Sanitize branch name to match image tag (CI_COMMIT_REF_SLUG from gitlab) | ||
| id: sanitize | ||
| env: | ||
| PR_REF: ${{ github.event.pull_request.head.ref }} | ||
| run: | # Match GitLab's CI_COMMIT_REF_SLUG: lowercase, non-alphanumeric → '-', collapse and trim | ||
| TAG=$(echo -n "$PR_REF" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | cut -c1-63 | sed -E 's/^-+//; s/-+$//') | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Delete image by tag from GHCR | ||
| env: | ||
| CI_COMMIT_REF_SLUG: ${{ steps.sanitize.outputs.tag }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh api "orgs/DataDog/packages/container/dd-trace-php%2Fdd-library-php/versions" \ | ||
| --jq ".[] | select(.metadata.container.tags[]? == \"${CI_COMMIT_REF_SLUG}\") | .id" \ | ||
| | xargs -r -I {} gh api "orgs/DataDog/packages/container/dd-trace-php%2Fdd-library-php/versions/{}" -X DELETE | ||
| echo "Deleted version with tag: ${CI_COMMIT_REF_SLUG}" | ||
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
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.
If you tie this to PRs, you probably also should restrict publishing docker images to branches having an associated PR as well.
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.
I added a test in the publish job, the job will exit with a warning if it runs on a branch without an associated PR
Maybe an
exit 0in that case can be desired, but I guess a warning makes it clearer that running the system tests on a feature branch will require an open PR and not only having the remote branch exist.Gate upload to having a PR open
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.
Looks good (with exit 3)