-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
954021c
commit 49fbdf1
Showing
9 changed files
with
163 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Github Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
tag: | ||
required: true | ||
type: string | ||
plugin: | ||
description: 'Plugin' | ||
required: true | ||
type: string | ||
environment: | ||
description: 'The O11 environment we are downloading from' | ||
required: true | ||
type: string | ||
notes: | ||
description: 'The release notes' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
download: | ||
name: '📦 Download OAP' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: '⬇️ Download the O11 OAP from LifeTime' | ||
id: download_file | ||
run: npm run download --plugin=${{inputs.plugin}} --environment=${{inputs.environment}} --lifetime=${{ secrets.LIFETIME }} --authentication='${{ secrets.AUTOMATION_TOKEN }}' | ||
|
||
- name: '🚀 Create GitHub Release' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
ls | ||
ls downloads | ||
gh release create ${{ inputs.tag }} './downloads/asset.oap' -t "${{inputs.tag}}" -n "${{inputs.notes}}" --latest=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const utils = require('./utils'); | ||
const fs = require("fs"); | ||
const { finished } = require('stream/promises'); | ||
const { Readable } = require('stream'); | ||
const path = require("path"); | ||
|
||
|
||
const DOWNLOAD_FOLDER = "downloads"; | ||
|
||
async function download(url) { | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
Authorization: auth | ||
} | ||
}) | ||
|
||
if(!response.ok || response.status != 200) { | ||
let error = await response.text(); | ||
console.error(error); | ||
throw Error("Couldn't download file :(((.") | ||
} | ||
let file = response.body; | ||
|
||
if (!fs.existsSync(DOWNLOAD_FOLDER)){ | ||
console.log("Create downloads folder: " + DOWNLOAD_FOLDER); | ||
fs.mkdirSync(DOWNLOAD_FOLDER); | ||
} | ||
|
||
const destination = path.resolve(`./${DOWNLOAD_FOLDER}/asset.oap`); | ||
const fileStream = fs.createWriteStream(destination, { flags: 'wx' }); | ||
await finished(Readable.fromWeb(file).pipe(fileStream)); | ||
console.log(`Finifhed writing to ${destination}`); | ||
} | ||
|
||
|
||
async function downloadOAP(baseURL, pluginName, inEnv, auth) { | ||
let envKey = await utils.getEnvironmentKey(baseURL, inEnv, auth); | ||
let pluginKey = await utils.getAppKey(baseURL, pluginName, auth); | ||
|
||
let downloadEndpoint = `${baseURL}/environments/${envKey}/applications/${pluginKey}/content` | ||
const response = await fetch(downloadEndpoint, { | ||
method: 'GET', | ||
headers: { | ||
Authorization: auth | ||
} | ||
}) | ||
|
||
if(response.ok && response.status == 200){ | ||
let downloadInfo = await response.json() | ||
await download(downloadInfo.url) | ||
} | ||
} | ||
|
||
let pluginSpaceName = process.env.npm_config_plugin; | ||
let baseURL = process.env.npm_config_lifetime; | ||
let auth = process.env.npm_config_authentication; | ||
let environment = process.env.npm_config_environment; | ||
baseURL = `https://${baseURL}/lifetimeapi/rest/v2`; | ||
|
||
|
||
|
||
downloadOAP(baseURL, pluginSpaceName, environment, auth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.