Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Jul 28, 2023
1 parent b997a2b commit 81904d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
44 changes: 22 additions & 22 deletions .github/actions-scripts/validate.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import {setFailed, setOutput} from '@actions/core';
function getRepoFromHubURL(url) {
if (url.host !== "github.com") {
throw "URL must be from github.com domain";
}

return url;
}
function run() {
import { setFailed, setOutput } from '@actions/core';
import * as toml from 'toml';
async function run() {
let { REPOSITORY: repository } = process.env
if (!repository) throw new Error('REPOSITORY env var is not set')
// repository 是否含有https://github.com/字段
if (repository.includes('https://github.com/')) {
try {
// When parsed the url will be like <https://hub.docker.com>
const url = new URL(repository.replace(/[<>]/g, ''));
repository = getRepoFromHubURL(url);
console.log(repository);
} catch (e) {
setFailed(e);
return;
}
}
if (repository.includes('https://raw.githubusercontent.com/')) {
try {
console.log(repository);
const response = await fetch(repository);
const data = await response.text();
const parsed = toml.parse(data);
setOutput('repository', repository);
setOutput('result','success');
setOutput('validation_output',parsed);
} catch (e) {
setFailed(e);
return;
}
}else{
setOutput('repository', repository);
setOutput('result','failure');
setOutput('validation_output',{'a':'b'});
}


setOutput('repository', repository);
}

run();
await run();
4 changes: 2 additions & 2 deletions .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
validation-succeeded:
runs-on: ubuntu-latest
needs: parse-issue
if: always() && (needs.parse-issue.result == 'success')
if: always() && (needs.parse-issue.outputs.result == 'success' && needs.parse-issue.outputs.validation_output != '')
steps:
- uses: actions/checkout@v3.3.0

Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
needs: parse-issue
if: |
always() &&
(needs.parse-issue.result == 'failure' && needs.parse-issue.outputs.validation_output != '')
(needs.parse-issue.outputs.result == 'failure' || needs.parse-issue.outputs.validation_output == '')
steps:
- uses: actions/checkout@v3.3.0

Expand Down

0 comments on commit 81904d9

Please sign in to comment.