mirror of
https://github.com/dagger/dagger-for-github.git
synced 2026-01-08 15:09:53 +11:00
update action to dagger 0.2
- Remove AGE key setup - Update README to use `dagger do` - Update tests to dagger 0.2 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
64f8bd95de
commit
24d6bfd692
96 changed files with 15028 additions and 70 deletions
144
test/cue.mod/pkg/universe.dagger.io/yarn/yarn.cue
vendored
Executable file
144
test/cue.mod/pkg/universe.dagger.io/yarn/yarn.cue
vendored
Executable file
|
|
@ -0,0 +1,144 @@
|
|||
// Yarn is a package manager for Javascript applications
|
||||
package yarn
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"dagger.io/dagger"
|
||||
|
||||
"universe.dagger.io/alpine"
|
||||
"universe.dagger.io/bash"
|
||||
"universe.dagger.io/docker"
|
||||
)
|
||||
|
||||
#Build: #Run & {
|
||||
buildDir: *"build" | string
|
||||
script: *"build" | string
|
||||
}
|
||||
|
||||
// Run a Yarn command
|
||||
#Run: {
|
||||
// Custom name for this command.
|
||||
// Assign an app-specific name if there are multiple apps in the same plan.
|
||||
name: string | *""
|
||||
|
||||
// App source code
|
||||
source: dagger.#FS
|
||||
|
||||
// Working directory to use
|
||||
cwd: *"." | string
|
||||
|
||||
// Write the contents of `environment` to this file, in the "envfile" format
|
||||
writeEnvFile: string | *""
|
||||
|
||||
// Optional: Read build output from this directory
|
||||
// Must be relative to working directory, cwd
|
||||
buildDir?: string
|
||||
|
||||
// Yarn script to run for this command.
|
||||
script: string
|
||||
|
||||
// Fix for shadowing issues
|
||||
let yarnScript = script
|
||||
|
||||
// Optional arguments for the script
|
||||
args: [...string] | *[]
|
||||
|
||||
// Secret variables
|
||||
// FIXME: not implemented. Are they needed?
|
||||
secrets: [string]: dagger.#Secret
|
||||
|
||||
container: #input: docker.#Image | *{
|
||||
// FIXME: Yarn's version depends on Alpine's version
|
||||
// Yarn version
|
||||
// yarnVersion: *"=~1.22" | string
|
||||
// FIXME: custom base image not supported
|
||||
alpine.#Build & {
|
||||
packages: {
|
||||
bash: {}
|
||||
yarn: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_run: docker.#Build & {
|
||||
steps: [
|
||||
container.#input,
|
||||
|
||||
docker.#Copy & {
|
||||
dest: "/src"
|
||||
contents: source
|
||||
},
|
||||
|
||||
bash.#Run & {
|
||||
// FIXME: move shell script to its own file
|
||||
script: contents: #"""
|
||||
yarn --cwd "$YARN_CWD" install --production false
|
||||
"""#
|
||||
|
||||
mounts: "yarn cache": {
|
||||
dest: "/cache/yarn"
|
||||
contents: dagger.#CacheDir & {
|
||||
// FIXME: are there character limitations in cache ID?
|
||||
id: "universe.dagger.io/yarn.#Run \(name)"
|
||||
}
|
||||
}
|
||||
|
||||
env: {
|
||||
YARN_CACHE_FOLDER: "/cache/yarn"
|
||||
YARN_CWD: cwd
|
||||
}
|
||||
|
||||
workdir: "/src"
|
||||
},
|
||||
|
||||
bash.#Run & {
|
||||
// FIXME: move shell script to its own file
|
||||
script: contents: #"""
|
||||
# Create $ENVFILE_NAME file if set
|
||||
[ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME"
|
||||
|
||||
opts=( $(echo $YARN_ARGS) )
|
||||
yarn --cwd "$YARN_CWD" run "$YARN_BUILD_SCRIPT" ${opts[@]}
|
||||
if [ ! -z "${YARN_BUILD_DIRECTORY:-}" ]; then
|
||||
mv "$YARN_BUILD_DIRECTORY" /build
|
||||
else
|
||||
mkdir /build
|
||||
fi
|
||||
"""#
|
||||
|
||||
mounts: "yarn cache": {
|
||||
dest: "/cache/yarn"
|
||||
contents: dagger.#CacheDir & {
|
||||
// FIXME: are there character limitations in cache ID?
|
||||
id: "universe.dagger.io/yarn.#Run \(name)"
|
||||
}
|
||||
}
|
||||
|
||||
env: {
|
||||
YARN_BUILD_SCRIPT: yarnScript
|
||||
YARN_ARGS: strings.Join(args, "\n")
|
||||
YARN_CACHE_FOLDER: "/cache/yarn"
|
||||
YARN_CWD: cwd
|
||||
if buildDir != _|_ {
|
||||
YARN_BUILD_DIRECTORY: buildDir
|
||||
}
|
||||
if writeEnvFile != "" {
|
||||
ENVFILE_NAME: writeEnvFile
|
||||
ENVFILE: strings.Join([ for k, v in env {"\(k)=\(v)"}], "\n")
|
||||
}
|
||||
}
|
||||
|
||||
workdir: "/src"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// The final contents of the package after run
|
||||
_output: dagger.#Subdir & {
|
||||
input: _run.output.rootfs
|
||||
path: "/build"
|
||||
}
|
||||
|
||||
output: _output.output
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue