{"id":15345456,"url":"https://github.com/jthomas/openwhiskaction","last_synced_at":"2025-03-27T18:43:55.586Z","repository":{"id":140706142,"uuid":"94458212","full_name":"jthomas/OpenWhiskAction","owner":"jthomas","description":"Swift Package for wrapping Swift functions to support execution as OpenWhisk Actions","archived":false,"fork":false,"pushed_at":"2018-03-27T16:13:15.000Z","size":18,"stargazers_count":0,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T21:42:20.387Z","etag":null,"topics":["openwhisk","serverless","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-15T16:25:53.000Z","updated_at":"2018-01-22T18:48:45.000Z","dependencies_parsed_at":"2024-07-16T17:17:42.387Z","dependency_job_id":null,"html_url":"https://github.com/jthomas/OpenWhiskAction","commit_stats":{"total_commits":5,"total_committers":3,"mean_commits":"1.6666666666666667","dds":0.6,"last_synced_commit":"f1caa8ff1297c1e6109a59beeda22240005c05a0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomas%2FOpenWhiskAction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomas%2FOpenWhiskAction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomas%2FOpenWhiskAction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthomas%2FOpenWhiskAction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jthomas","download_url":"https://codeload.github.com/jthomas/OpenWhiskAction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245905101,"owners_count":20691730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openwhisk","serverless","swift"],"created_at":"2024-10-01T11:13:26.656Z","updated_at":"2025-03-27T18:43:55.561Z","avatar_url":"https://github.com/jthomas.png","language":"Swift","readme":"# OpenWhiskAction\nSwift Package for wrapping Swift functions to support execution as OpenWhisk actions\n\n## installation\n\nInstall the package by adding the dependency to `Package.swift`.\n\n```swift\nlet package = Package(\n    name: \"Action\",\n    dependencies: [\n        .Package(url: \"https://github.com/jthomas/OpenWhiskAction.git\", majorVersion: 0)\n    ]\n)\n```\n\n## usage\n\nThis package exposes a public function (`OpenWhiskAction` ) that should be called with a function reference (`([String: Any]) -\u003e [String: Any])`) as a named parameter (`main`). The callback will be executed with the invocation parameters. Returned values will be serialised as the invocation response.\n\n```swift\nimport OpenWhiskAction\n\nfunc hello(args: [String:Any]) -\u003e [String:Any] {\n    if let name = args[\"name\"] as? String {\n      return [ \"greeting\" : \"Hello \\(name)!\" ]\n    } else {\n      return [ \"greeting\" : \"Hello stranger!\" ]\n    }\n}\n\nOpenWhiskAction(main: hello)\n```\n\nThis source file should be compiled into a binary for deployment to OpenWhisk.\n\n## compiling with docker\n\nOpenWhisk actions for the Swift runtime use a [custom Docker image]() as the runtime environment. Compiling the application binary using this image will ensure it is compatible with the platform runtime. \n\nThis command will run the `swift build` system within a container from this image. The host filesystem is mounted into the container at `/swift-package`. Binaries and other build artifacts will be available in `./.build/release/` after the command has executed.\n\n```\ndocker run --rm -it -v $(pwd):/swift-package openwhisk/swift3action bash -e -c \"cd /swift-package \u0026\u0026 swift build -v -c release\"\n```\n\n## deploying to openwhisk\n\nOpenWhisk actions can be created from a zip file containing the action artifacts. The zip file will be expanded prior to execution. In the Swift environment, the compiled Swift binary executed by the platform is expected to be at `./.build/release/Action`. \n\nIf an action is deployed from a zip file which contains this file, the runtime will execute this binary rather than compiling a new binary from source code within the zip file.\n\n```sh\n$ zip action.zip .build/release/Action\n  adding: .build/release/Action (deflated 67%)\n$ wsk action create swift-action --kind swift:3 action.zip\nok: created action swift-action\n$ wsk action invoke --blocking --result -p name \"Bernie Sanders\" swift-action\n{\n    \"greeting\": \"Hello Bernie Sanders!\"\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomas%2Fopenwhiskaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjthomas%2Fopenwhiskaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthomas%2Fopenwhiskaction/lists"}