-
Notifications
You must be signed in to change notification settings - Fork 12
ci(docker-compose): Add Docker Compose publication to ghcr.
#439
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
base: main
Are you sure you want to change the base?
Changes from 25 commits
11c9b5a
470f7e5
139286e
bb36fec
07baeee
c6d4696
ce11907
4c7b4c0
7f2d8f3
6b92262
bc35203
1bf2687
d3dbf06
0d6b169
b3eed39
98ebc3b
07f764e
ab5a157
d5c1a02
7807436
95f30cf
0ccb692
c65ae75
09ec079
4916186
9729ac7
152ab8e
43ede1f
fba8922
a0dbcb5
3c8f3b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||||||||
| name: "spider-compose" | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| pull_request: | ||||||||||||||
| paths: &monitored_paths | ||||||||||||||
| - ".github/workflows/spider-compose.yaml" | ||||||||||||||
| - "taskfile.yaml" | ||||||||||||||
| - "taskfiles/docker.yaml" | ||||||||||||||
| - "tools/deployment/spider-compose/**" | ||||||||||||||
| - "tools/yscope-dev-utils" | ||||||||||||||
| push: | ||||||||||||||
| branches: ["main"] | ||||||||||||||
| paths: *monitored_paths | ||||||||||||||
| tags: ["spider-huntsman-v*"] | ||||||||||||||
| workflow_dispatch: | ||||||||||||||
|
|
||||||||||||||
| permissions: {} | ||||||||||||||
|
|
||||||||||||||
| concurrency: | ||||||||||||||
| group: "${{github.workflow}}-${{github.ref}}" | ||||||||||||||
|
|
||||||||||||||
| # Cancel in-progress jobs for efficiency. Exclude the `main` branch to allow uninterrupted | ||||||||||||||
| # publishing of Docker Compose OCI artifacts. | ||||||||||||||
| cancel-in-progress: "${{github.ref != 'refs/heads/main'}}" | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| validate: | ||||||||||||||
| runs-on: "ubuntu-latest" | ||||||||||||||
| steps: | ||||||||||||||
| - uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 | ||||||||||||||
| with: | ||||||||||||||
| submodules: "recursive" | ||||||||||||||
|
|
||||||||||||||
| - uses: "./tools/yscope-dev-utils/exports/github/actions/install-go-task" | ||||||||||||||
|
sitaowang1998 marked this conversation as resolved.
|
||||||||||||||
|
|
||||||||||||||
| - name: "Validate Docker Compose configuration" | ||||||||||||||
| shell: "bash" | ||||||||||||||
| run: "task docker:compose:validate" | ||||||||||||||
|
|
||||||||||||||
| publish: | ||||||||||||||
| if: "github.event_name != 'pull_request'" | ||||||||||||||
|
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.
Suggested change
Collaborator
Author
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. We use tag instead of branch for release.
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. so say we have a tag called spider-huntsman-v0.0.1, does this workflow gets triggered?
Collaborator
Author
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. Yes. Adding a tag triggers a |
||||||||||||||
| needs: "validate" | ||||||||||||||
| runs-on: "ubuntu-latest" | ||||||||||||||
| permissions: | ||||||||||||||
| contents: "read" | ||||||||||||||
| packages: "write" | ||||||||||||||
| steps: | ||||||||||||||
| - uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 | ||||||||||||||
|
sitaowang1998 marked this conversation as resolved.
Outdated
|
||||||||||||||
| with: | ||||||||||||||
| submodules: "recursive" | ||||||||||||||
|
|
||||||||||||||
| - uses: "./tools/yscope-dev-utils/exports/github/actions/install-go-task" | ||||||||||||||
|
20001020ycx marked this conversation as resolved.
|
||||||||||||||
|
|
||||||||||||||
| - uses: "oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d" # v2.0.1 | ||||||||||||||
| with: | ||||||||||||||
| version: "1.3.3" | ||||||||||||||
|
|
||||||||||||||
| - name: "Sanitize repository name" | ||||||||||||||
| id: "repo" | ||||||||||||||
| run: >- | ||||||||||||||
| echo "name=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" | ||||||||||||||
|
|
||||||||||||||
| - name: "Get artifact tag" | ||||||||||||||
| id: "artifact" | ||||||||||||||
| shell: "bash" | ||||||||||||||
| run: |- | ||||||||||||||
| tag="nightly" | ||||||||||||||
|
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. Wait, are we doing nightly? if so should we add something like
Collaborator
Author
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. I don't see the need to trigger publication everyday. The
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. then I guess my question is why tagged with Could you clarify for me how this term is defined in spider. In fact, Spider seldom uses this terminology - three instances only, but I do saw other worfklow used
Collaborator
Author
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. I have added |
||||||||||||||
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | ||||||||||||||
| tag="${GITHUB_REF_NAME}" | ||||||||||||||
| fi | ||||||||||||||
|
sitaowang1998 marked this conversation as resolved.
|
||||||||||||||
| echo "tag=${tag}" >> "$GITHUB_OUTPUT" | ||||||||||||||
|
|
||||||||||||||
| - uses: "docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121" # v4.1.0 | ||||||||||||||
| with: | ||||||||||||||
| registry: "ghcr.io" | ||||||||||||||
| username: "${{github.actor}}" | ||||||||||||||
| password: "${{secrets.GITHUB_TOKEN}}" | ||||||||||||||
|
|
||||||||||||||
| - name: "Publish Docker Compose OCI artifact" | ||||||||||||||
| shell: "bash" | ||||||||||||||
| run: >- | ||||||||||||||
| task docker:compose:publish | ||||||||||||||
| OCI_REFERENCE='ghcr.io/${{steps.repo.outputs.name}}/compose:${{steps.artifact.outputs.tag}}' | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,22 @@ tasks: | |
| dir: "{{.G_SPIDER_COMPOSE_DIR}}" | ||
| cmd: "docker compose --env-file .env.example --file compose.yaml config --quiet" | ||
|
|
||
| # Publishes the complete Docker Compose deployment directory as an OCI artifact. | ||
| # | ||
| # @param {string} OCI_REFERENCE The destination OCI reference, including its tag. | ||
|
sitaowang1998 marked this conversation as resolved.
Outdated
|
||
| compose:publish: | ||
| requires: | ||
| vars: ["OCI_REFERENCE"] | ||
| deps: ["compose:validate"] | ||
| dir: "{{.G_SPIDER_COMPOSE_DIR}}/.." | ||
| cmd: >- | ||
| oras push | ||
| --artifact-type "application/vnd.yscope.spider.compose.v1" | ||
|
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. Are we using v1? I thought we have moved on towards v2,
Collaborator
Author
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. This has nothing to do with docker compose version. It is a version we define ourselves. I'll remove it to avoid confusion. |
||
| '{{.OCI_REFERENCE}}' | ||
| "spider-compose/compose.yaml:application/yaml" | ||
| "spider-compose/configs/:application/vnd.yscope.spider.compose.configs.v1.tar" | ||
|
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. Ditto |
||
| "spider-compose/.env.example:text/plain" | ||
|
|
||
| compose:up: | ||
| dir: "{{.G_SPIDER_COMPOSE_DIR}}" | ||
| cmd: "docker compose --file compose.yaml up --detach --wait --wait-timeout 300" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.