Check context type

Signed-off-by: CrazyMax <[email protected]>
This commit is contained in:
CrazyMax
2020-08-16 19:13:19 +02:00
parent 10b9d7ec22
commit 9c473659de
6 changed files with 835 additions and 4 deletions
+4 -1
View File
@@ -81,8 +81,11 @@ jobs:
-
name: Build and push
uses: ./
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REF: ${{ github.ref }}
with:
context: "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}#${{ github.ref }}"
context: ${{ github.repositoryUrl }}
file: ./test/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64,linux/386
+1
View File
@@ -6,6 +6,7 @@ ___
* [Usage](#usage)
* [Quick start](#quick-start)
* [Bake](#bake)
* [Customizing](#customizing)
* [inputs](#inputs)
* [outputs](#outputs)
Generated Vendored
+755 -1
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -27,9 +27,11 @@
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.4",
"@actions/tool-cache": "^1.5.5"
"@actions/tool-cache": "^1.5.5",
"git-url-parse": "^11.1.3"
},
"devDependencies": {
"@types/git-url-parse": "^9.0.0",
"@types/node": "^14.0.14",
"@zeit/ncc": "^0.22.3",
"prettier": "^2.0.5",
+17 -1
View File
@@ -1,3 +1,4 @@
import gitUrlParse from 'git-url-parse';
import * as core from '@actions/core';
export interface Inputs {
@@ -24,7 +25,7 @@ export interface Inputs {
export async function getInputs(): Promise<Inputs> {
return {
context: core.getInput('context') || '.',
context: await getBuildContext(),
file: core.getInput('file') || './Dockerfile',
buildArgs: await getInputList('build-args'),
labels: await getInputList('labels'),
@@ -65,6 +66,21 @@ export async function getArgs(inputs: Inputs): Promise<Array<string>> {
return args;
}
async function getBuildContext(): Promise<string> {
let context: string = core.getInput('context');
if (!context) {
return '.';
}
try {
const gitURL = gitUrlParse(context);
gitURL.token = gitURL.token || process.env['GIT_TOKEN'] || process.env['GITHUB_TOKEN'] || '';
gitURL.ref = gitURL.ref || process.env['GIT_REF'] || process.env['GITHUB_REF'] || '';
return gitURL.toString();
} catch {
return context;
}
}
async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = [];
if (inputs.noCache) {
+55
View File
@@ -38,6 +38,11 @@
semver "^6.1.0"
uuid "^3.3.2"
"@types/git-url-parse@^9.0.0":
version "9.0.0"
resolved "https://registry.yarnpkg.com/@types/git-url-parse/-/git-url-parse-9.0.0.tgz#aac1315a44fa4ed5a52c3820f6c3c2fb79cbd12d"
integrity sha512-kA2RxBT/r/ZuDDKwMl+vFWn1Z0lfm1/Ik6Qb91wnSzyzCDa/fkM8gIOq6ruB7xfr37n6Mj5dyivileUVKsidlg==
"@types/node@^14.0.14":
version "14.0.27"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1"
@@ -68,6 +73,28 @@ editorconfig@^0.15.0:
semver "^5.6.0"
sigmund "^1.0.1"
git-up@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/git-up/-/git-up-4.0.2.tgz#10c3d731051b366dc19d3df454bfca3f77913a7c"
integrity sha512-kbuvus1dWQB2sSW4cbfTeGpCMd8ge9jx9RKnhXhuJ7tnvT+NIrTVfYZxjtflZddQYcmdOTlkAcjmx7bor+15AQ==
dependencies:
is-ssh "^1.3.0"
parse-url "^5.0.0"
git-url-parse@^11.1.3:
version "11.1.3"
resolved "https://registry.yarnpkg.com/git-url-parse/-/git-url-parse-11.1.3.tgz#03625b6fc09905e9ad1da7bb2b84be1bf9123143"
integrity sha512-GPsfwticcu52WQ+eHp0IYkAyaOASgYdtsQDIt4rUp6GbiNt1P9ddrh3O0kQB0eD4UJZszVqNT3+9Zwcg40fywA==
dependencies:
git-up "^4.0.0"
is-ssh@^1.3.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.3.2.tgz#a4b82ab63d73976fd8263cceee27f99a88bdae2b"
integrity sha512-elEw0/0c2UscLrNG+OAorbP539E3rhliKPg+hDMWN9VwrDXfYK+4PBEykDPfxlYYtQvl84TascnQyobfQLHEhQ==
dependencies:
protocols "^1.1.0"
lru-cache@^4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
@@ -76,11 +103,39 @@ lru-cache@^4.1.5:
pseudomap "^1.0.2"
yallist "^2.1.2"
normalize-url@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559"
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
parse-path@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-4.0.2.tgz#ef14f0d3d77bae8dd4bc66563a4c151aac9e65aa"
integrity sha512-HSqVz6iuXSiL8C1ku5Gl1Z5cwDd9Wo0q8CoffdAghP6bz8pJa1tcMC+m4N+z6VAS8QdksnIGq1TB6EgR4vPR6w==
dependencies:
is-ssh "^1.3.0"
protocols "^1.4.0"
parse-url@^5.0.0:
version "5.0.2"
resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-5.0.2.tgz#856a3be1fcdf78dc93fc8b3791f169072d898b59"
integrity sha512-Czj+GIit4cdWtxo3ISZCvLiUjErSo0iI3wJ+q9Oi3QuMYTI6OZu+7cewMWZ+C1YAnKhYTk6/TLuhIgCypLthPA==
dependencies:
is-ssh "^1.3.0"
normalize-url "^3.3.0"
parse-path "^4.0.0"
protocols "^1.4.0"
prettier@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
protocols@^1.1.0, protocols@^1.4.0:
version "1.4.8"
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8"
integrity sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"