-
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.
Merge pull request #37 from OutSystems/development
Merge `development` into `main`:: RMET-3619 :: Fix LifeTime Deployment Automation (#36)
- Loading branch information
Showing
5 changed files
with
153 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
name: (O11) Release Plugin | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
inputs: | ||
plugin: | ||
description: 'Name of the plugin in O11' | ||
required: true | ||
type: string | ||
jobs: | ||
deploy: | ||
name: '🔌 Deploy plugin across LifeTime' | ||
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: Tag Plugin with Version | ||
run: npm run update:version --plugin="${{inputs.plugin}}" --lifetime=${{ secrets.LIFETIME}} --authentication='${{secrets.AUTOMATION_TOKEN}}' | ||
|
||
- name: ⏳ Wait for tag version to propagate | ||
run: sleep 20 # Waits for 20 seconds | ||
|
||
- name: Deploying from DEV to TST | ||
run: npm run deploy --plugin="${{inputs.plugin}}" --from=Development --to=Testing --lifetime=${{ secrets.LIFETIME }} --authentication='${{ secrets.AUTOMATION_TOKEN }}' | ||
|
||
- name: ⏳ Wait for deployment to propagate | ||
run: sleep 20 # Waits for 20 seconds | ||
|
||
- name: Deploying from TST to PROD | ||
run: npm run deploy --plugin="${{inputs.plugin}}" --from=Testing --to=Production --lifetime=${{ secrets.LIFETIME }} --authentication='${{ secrets.AUTOMATION_TOKEN }}' |
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 |
---|---|---|
@@ -1,64 +1,20 @@ | ||
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, fileName) { | ||
|
||
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}/${fileName}`); | ||
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, version, 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 | ||
} | ||
}) | ||
console.log(version) | ||
if(response.ok && response.status == 200){ | ||
let downloadInfo = await response.json() | ||
await download(downloadInfo.url, `v${version}.oap`) | ||
} | ||
let downloadURL = await utils.requestDownloadURL(baseURL, envKey, pluginKey, auth); | ||
|
||
let file = await utils.download(downloadURL, auth) | ||
await utils.save(file, `v${version}.oap`); | ||
} | ||
|
||
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; | ||
let forgeVersion = process.env.npm_config_forge; | ||
console.log(forgeVersion) | ||
|
||
baseURL = `https://${baseURL}/lifetimeapi/rest/v2`; | ||
|
||
downloadOAP(baseURL, pluginSpaceName, environment, forgeVersion, 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