mirror of
https://gitea.com/actions/upload-artifact.git
synced 2025-04-22 00:35:32 +08:00
add pages deployment step
This commit is contained in:
parent
7cc38ae471
commit
b9415707f9
18
dist/index.js
vendored
18
dist/index.js
vendored
@ -5542,19 +5542,31 @@ function run() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`);
|
core.info(`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`);
|
||||||
}
|
|
||||||
let runtimeUrl = process.env['ACTIONS_RUNTIME_URL'];
|
let runtimeUrl = process.env['ACTIONS_RUNTIME_URL'];
|
||||||
console.log(runtimeUrl);
|
|
||||||
const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`;
|
const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`;
|
||||||
const response = yield axios_1.default.get(artifactUrl, {
|
let response = yield axios_1.default.get(artifactUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`,
|
"Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`,
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const unsignedUrl = response.data.value[0].url;
|
||||||
|
console.log(response);
|
||||||
|
console.log(`unsigned artifact url is ${unsignedUrl}`);
|
||||||
|
response = yield axios_1.default.post("api.github.com/repos/github/hub/pages/deployment", {
|
||||||
|
artifact_url: unsignedUrl,
|
||||||
|
pages_build_version: process.env['GITHUB_SHA']
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/vnd.github.v3+json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": `Bearer ${process.env['GITHUB_TOKEN']}`
|
||||||
|
}
|
||||||
|
});
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.setFailed(err.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
|
@ -67,18 +67,30 @@ async function run(): Promise<void> {
|
|||||||
core.info(
|
core.info(
|
||||||
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
||||||
)
|
)
|
||||||
}
|
|
||||||
let runtimeUrl = process.env['ACTIONS_RUNTIME_URL']
|
let runtimeUrl = process.env['ACTIONS_RUNTIME_URL']
|
||||||
console.log(runtimeUrl)
|
|
||||||
const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`;
|
const artifactUrl = `${runtimeUrl}_apis/pipelines/workflows/${process.env['GITHUB_RUN_ID']}/artifacts?api-version=6.0-preview`;
|
||||||
const response = await axios.get(artifactUrl, {
|
let response = await axios.get(artifactUrl, {
|
||||||
headers:{
|
headers:{
|
||||||
"Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`,
|
"Authorization": `Bearer ${process.env["ACTIONS_RUNTIME_TOKEN"]}`,
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const unsignedUrl = response.data.value[0].url
|
||||||
|
console.log(response)
|
||||||
|
console.log(`unsigned artifact url is ${unsignedUrl}`)
|
||||||
|
response = await axios.post("api.github.com/repos/github/hub/pages/deployment", {
|
||||||
|
artifact_url: unsignedUrl,
|
||||||
|
pages_build_version: process.env['GITHUB_SHA']
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/vnd.github.v3+json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": `Bearer ${process.env['GITHUB_TOKEN']}`
|
||||||
|
}
|
||||||
|
})
|
||||||
console.log(response.data)
|
console.log(response.data)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.setFailed(err.message)
|
core.setFailed(err.message)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user