Skip to content

Commit

Permalink
Merge pull request #24 from metrik-tech/feature/ENG-172
Browse files Browse the repository at this point in the history
ENG-172: add support for publishing SDK to metrik S3 server upon new …
  • Loading branch information
4x8Matrix authored Jun 30, 2024
2 parents 6b3f1dd + d808d29 commit 4ea2d1e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/on-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches: [ "*" ]

jobs:
upload-artifact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ok-nick/[email protected]
- name: Build artifact dependencies
run: wally install
- name: Build artifact
run: rojo build default.project.json -o Artifact.rbxm
- name: Deploy artifact
run: lune run deploy Artifact.rbxm
37 changes: 37 additions & 0 deletions .lune/deploy.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local process = require("@lune/process")
local net = require("@lune/net")
local fs = require("@lune/fs")

local artifact = process.args[1]
local commitHash = process.env.GITHUB_SHA
local authorization = process.env.SDK_ARTIFACT_UPLOAD_SECRET

local multiformUuid = `SDK_WORKFLOW.{math.random()}`
local multiformContentBoundary = `{multiformUuid}`
local multiformContent = ""

multiformContent ..= `--{multiformContentBoundary}\r\n`
multiformContent ..= `Content-Disposition: form-data; name="commitHash"\r\n`
multiformContent ..= `Content-Type: application/json\r\n`

multiformContent ..= `\r\n`
multiformContent ..= `{commitHash}\r\n`

multiformContent ..= `--{multiformContentBoundary}\r\n`
multiformContent ..= `Content-Disposition: form-data; name="file"; filename="file.rbxm"\r\n`
multiformContent ..= `Content-Type: application/octet-stream\r\n`

multiformContent ..= `\r\n`
multiformContent ..= `{fs.readFile(artifact)}\r\n`

multiformContent ..= `--{multiformContentBoundary}--\r\n`

print(net.request({
url = "https://preview.metrik.app/api/sdk/upload-artifact",
method = "POST",
headers = {
["Authorization"] = `Bearer {authorization}`,
["content-type"] = `multipart/form-data; boundary={multiformContentBoundary}`
},
body = multiformContent
}))
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"luau-lsp.sourcemap.rojoProjectFile": "development.project.json"
"luau-lsp.sourcemap.rojoProjectFile": "development.project.json",
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": {
"@lune/": "~/.lune/.typedefs/0.8.6/"
}
}
1 change: 1 addition & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ wally = "UpliftGames/[email protected]"
wally-package-types = "JohnnyMorganz/[email protected]"
luaulsp = "JohnnyMorganz/[email protected]"
zap = "red-blox/[email protected]"
lune = "lune-org/[email protected]"

0 comments on commit 4ea2d1e

Please sign in to comment.