Skip to content

Instantly share code, notes, and snippets.

@rockyburt
Created July 3, 2022 22:17
Show Gist options
  • Save rockyburt/c8b3192b68f89973f924490527d53e7c to your computer and use it in GitHub Desktop.
Save rockyburt/c8b3192b68f89973f924490527d53e7c to your computer and use it in GitHub Desktop.
// cue snippet
// when "dagger do notifyEndRelease" is run, notifyStartRelease is not run, but shouldn't it be ??
#SlackPost: {
input: *_baseImage.output | docker.#Image
token: dagger.#Secret
channel: string
message: string
broadcast: *false | bool
always: *false | bool
thread?: string
output: _post.output
_baseImage: #SlackNotifyImage
_broadcastClause: *"" | string
if broadcast {
_broadcastClause: " -b"
}
_threadClause: *"" | string
if thread != _|_ {
_threadClause: " -t " + thread
}
_newThreadFile: "/slack/new-thread.txt"
rawThreadResult: core.#ReadFile & {
"input": _post.output.rootfs
path: _newThreadFile
}
threadResult: rawThreadResult.contents
_post: bash.#Run & {
"input": input
"always": always
env: {
SLACK_OAUTH_TOKEN: token
SLACK_CHANNEL: channel
}
script: contents: """
echo -n $(python3 /slack/files/slack.py \(_threadClause) \(_broadcastClause) --display-thread "\(message)") > "\(_newThreadFile)"
"""
}
}
steps: [
notifyStartRelease: #SlackPost & {
token: client.env.SLACK_OAUTH_TOKEN
channel: client.env.SLACK_CHANNEL
message: "CI: beginning build"
always: true
}
notifyEndRelease: #SlackPost & {
token: client.env.SLACK_OAUTH_TOKEN
channel: client.env.SLACK_CHANNEL
thread: notifyStartRelease.rawThreadResult.contents
broadcast: true
message: "CI: completed build XXX" // \(saveAppImage.imageID)"
always: true
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment