-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 85ada6c
Showing
12 changed files
with
1,722 additions
and
0 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,13 @@ | ||
{ | ||
"env": { | ||
"commonjs": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": "airbnb-base", | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"rules": { | ||
} | ||
} |
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,3 @@ | ||
.DS_Store | ||
node_modules | ||
yarn-error.log |
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,2 @@ | ||
version-tag-prefix "" | ||
version-git-message ":bookmark: %s" |
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,17 @@ | ||
# Contributing | ||
|
||
## Drafting a release | ||
|
||
```sh | ||
# Build the action | ||
yarn prepare | ||
|
||
# Add the files to git | ||
git add . | ||
|
||
# Bump the version | ||
yarn version --patch|minor|major | ||
|
||
# Push with tags | ||
git push origin main --tags | ||
``` |
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,26 @@ | ||
# Deploy on Scalingo | ||
|
||
This action will allow you to deploy your app to Scalingo. | ||
It was created to work around the limitation of Scalingo to deploy only after the CI is valid. | ||
|
||
> ⚠️ This action works only for Scalingo apps that are linked to GitHub | ||
## Getting started | ||
|
||
```yaml | ||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Scalingo Deploy | ||
uses: derniercri/[email protected] | ||
with: | ||
# Required | ||
token: ${{ secrets.SCALINGO_TOKEN }} | ||
appName: YOUR_SCALINGO_APP_NAME | ||
# Optional | ||
apiUrl: "The API URL endpoint, defaults to https://api.osc-fr1.scalingo.com. The list is available here: https://developers.scalingo.com/index#global-information" | ||
branch: The branch to deploy, defaults to the current branch | ||
``` |
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,21 @@ | ||
name: Scalingo Deploy | ||
description: Trigger a deployment to Scalingo | ||
inputs: | ||
token: | ||
description: Your Scalingo API Token (generate it in your profile settings) | ||
required: true | ||
apiUrl: | ||
description: Scalingo's base API URL | ||
required: true | ||
default: https://api.osc-fr1.scalingo.com | ||
appName: | ||
description: Your Scalingo application name | ||
required: true | ||
branch: | ||
description: The target branch to deploy (defaults to current branch on push and head ref on pull request) | ||
# outputs: | ||
# time: # id of output | ||
# description: 'The time we greeted you' | ||
runs: | ||
using: node20 | ||
main: dist/index.js |
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
{ | ||
"name": "scalingo-deploy", | ||
"version": "1.0.0", | ||
"description": "Trigger a deployment to your Scalingo app", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@actions/core": "^1.10.1", | ||
"@actions/github": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@vercel/ncc": "^0.38.1", | ||
"eslint": "^7.32.0 || ^8.2.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.25.2" | ||
}, | ||
"scripts": { | ||
"lint": "yarn eslint 'src/**/*.js'", | ||
"lint:fix": "yarn lint --fix", | ||
"prepare": "yarn ncc build src/index.js -o dist --minify" | ||
} | ||
} |
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,30 @@ | ||
const core = require('@actions/core'); | ||
const { apiUrl, token, appName } = require('./constants'); | ||
|
||
const createDeployment = (bearerToken, branch) => fetch(`${apiUrl}/v1/apps/${appName}/scm_repo_link/manual_deploy`, { | ||
method: 'POST', | ||
body: JSON.stringify({ branch }), | ||
headers: { | ||
Authorization: `Bearer ${bearerToken}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
.then((res) => { | ||
core.debug(res); | ||
return res; | ||
}) | ||
.then((res) => res.json()); | ||
|
||
const getBearerToken = () => fetch('https://auth.scalingo.com/v1/tokens/exchange', { | ||
method: 'POST', | ||
headers: { | ||
Authorization: `Basic ${Buffer.from(`:${token}`).toString('base64')}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
.then((res) => res.json()); | ||
|
||
module.exports = { | ||
createDeployment, | ||
getBearerToken, | ||
}; |
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,10 @@ | ||
const core = require('@actions/core'); | ||
|
||
const apiUrl = core.getInput('apiUrl'); | ||
const appName = core.getInput('appName'); | ||
const token = core.getInput('token'); | ||
const branch = core.getInput('branch'); | ||
|
||
module.exports = { | ||
apiUrl, appName, branch, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const { createDeployment, getBearerToken } = require('./api'); | ||
const { branch } = require('./constants'); | ||
|
||
const getBranchToDeploy = () => { | ||
if (branch) { | ||
return branch; | ||
} | ||
|
||
const { ref, eventName } = github.context; | ||
|
||
if (eventName === 'pull_request') { | ||
return process.env.GITHUB_HEAD_REF; | ||
} | ||
|
||
if (ref.startsWith('refs/heads/')) { | ||
return ref.replace('refs/heads/', ''); | ||
} | ||
if (ref.startsWith('refs/tags/')) { | ||
return ref.replace('refs/tags/', ''); | ||
} | ||
return ref; | ||
}; | ||
|
||
const main = async () => { | ||
try { | ||
const { token } = await getBearerToken(); | ||
const targetBranch = getBranchToDeploy(); | ||
|
||
await createDeployment(token, targetBranch); | ||
} catch (err) { | ||
core.error(err); | ||
} | ||
}; | ||
|
||
main(); |
Oops, something went wrong.