Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
af514b7
Just a commit
DmitryKuzmenko Aug 20, 2024
c499b77
Test custom check
DmitryKuzmenko Aug 21, 2024
2ae5313
Simulate deploy-destroy jobs for test
DmitryKuzmenko Aug 21, 2024
5bc4cec
Fixups
DmitryKuzmenko Aug 21, 2024
a939070
Test always-on step
DmitryKuzmenko Aug 21, 2024
18b4f83
Script test
DmitryKuzmenko Aug 22, 2024
2c4d561
One more test update
DmitryKuzmenko Aug 22, 2024
5e2969a
Fixup
DmitryKuzmenko Aug 22, 2024
a77772c
Another test
DmitryKuzmenko Aug 22, 2024
80ba1dd
Don't fail
DmitryKuzmenko Aug 22, 2024
45cefd5
More complexity
DmitryKuzmenko Aug 22, 2024
53fb4fc
One more test
DmitryKuzmenko Aug 22, 2024
08a6745
Update
DmitryKuzmenko Aug 22, 2024
e075ce5
Fixup
DmitryKuzmenko Aug 22, 2024
8480ad9
Async test
DmitryKuzmenko Aug 28, 2024
73b931b
Test JS action
DmitryKuzmenko Aug 28, 2024
1d3b85b
Fixup
DmitryKuzmenko Aug 28, 2024
7656b62
Debug
DmitryKuzmenko Aug 28, 2024
0bef0e6
Debug
DmitryKuzmenko Aug 28, 2024
69d7f27
git add js action
DmitryKuzmenko Aug 28, 2024
a170c91
Init npm
DmitryKuzmenko Aug 28, 2024
b6b94c7
Add node modules
DmitryKuzmenko Aug 28, 2024
576b594
Test payload head ref
DmitryKuzmenko Aug 28, 2024
2c93ab1
Fixup
DmitryKuzmenko Aug 28, 2024
7ccf1d3
Fixup
DmitryKuzmenko Aug 28, 2024
be82525
Debug
DmitryKuzmenko Aug 28, 2024
8312813
Fixup
DmitryKuzmenko Aug 28, 2024
11d600f
cleanup
DmitryKuzmenko Aug 28, 2024
2bd27b5
Import netlify
DmitryKuzmenko Aug 28, 2024
075e33b
Update node_modules
DmitryKuzmenko Aug 28, 2024
859fd69
Update
DmitryKuzmenko Aug 28, 2024
5b4f111
Update
DmitryKuzmenko Aug 29, 2024
b66721a
Update
DmitryKuzmenko Aug 29, 2024
0f2bb04
Update
DmitryKuzmenko Aug 29, 2024
cf6e4f8
Fixup
DmitryKuzmenko Aug 29, 2024
8eb12a3
Update
DmitryKuzmenko Aug 29, 2024
a2afea5
Update
DmitryKuzmenko Aug 29, 2024
e1d7164
Update
DmitryKuzmenko Aug 29, 2024
964c0fe
Update
DmitryKuzmenko Aug 29, 2024
120432d
Update
DmitryKuzmenko Aug 29, 2024
c28e57c
Update
DmitryKuzmenko Aug 29, 2024
5253fc8
Update
DmitryKuzmenko Aug 29, 2024
120f641
Fixup
DmitryKuzmenko Aug 29, 2024
766ef74
Fixup
DmitryKuzmenko Aug 29, 2024
4179c5e
Script experiment
DmitryKuzmenko Aug 29, 2024
88918c4
Update
DmitryKuzmenko Aug 29, 2024
3cc95fa
Fixup
DmitryKuzmenko Aug 29, 2024
db19c86
Fixup
DmitryKuzmenko Aug 29, 2024
c8db367
Attempt to fix
DmitryKuzmenko Aug 29, 2024
9cd446f
Fixup for import
DmitryKuzmenko Aug 29, 2024
434b3d2
Debug
DmitryKuzmenko Aug 29, 2024
05e9ba2
Fixup arguments
DmitryKuzmenko Aug 29, 2024
e349e40
Update
DmitryKuzmenko Aug 29, 2024
c859956
Update
DmitryKuzmenko Aug 30, 2024
2563ff2
Test: remove npm install
DmitryKuzmenko Aug 30, 2024
dd609d3
Test
DmitryKuzmenko Aug 30, 2024
14d4c43
Output update
DmitryKuzmenko Aug 30, 2024
c78ddcc
Test
DmitryKuzmenko Aug 30, 2024
c816981
Add file. Updates
DmitryKuzmenko Sep 2, 2024
1273f1b
Test
DmitryKuzmenko Sep 4, 2024
4753343
Fixup
DmitryKuzmenko Sep 4, 2024
d9542c4
Fixup
DmitryKuzmenko Sep 4, 2024
5544aa7
Fixup
DmitryKuzmenko Sep 4, 2024
e288c04
Fixup
DmitryKuzmenko Sep 4, 2024
c7e0044
Pring payload
DmitryKuzmenko Sep 4, 2024
da304ee
Check head ref
DmitryKuzmenko Sep 4, 2024
c977ae8
Test list comments
DmitryKuzmenko Sep 5, 2024
5ee2c7a
Cleanup comments
DmitryKuzmenko Sep 5, 2024
39b5e62
Test
DmitryKuzmenko Sep 5, 2024
0c73ed7
Update
DmitryKuzmenko Sep 5, 2024
d9970ab
Test
DmitryKuzmenko Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/actions/js-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'JS Action'
description: 'Test JS Action'
inputs:
name:
description: 'Site name'
required: true
id:
description: 'Site id'
required: true
title:
description: 'Title'
required: true
payload:
description: 'payload'
required: true
token:
description: 'token'
required: true
runs:
using: 'node20'
main: 'index.js'
123 changes: 123 additions & 0 deletions .github/actions/js-action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { NetlifyAPI } from "netlify";

import * as core from "@actions/core";
import * as github from "@actions/github";
import https from "node:https";

try {
const name = core.getInput("name");
const site_id = core.getInput("id");
const title = core.getInput("title");
const netlify_payload = core.getInput("payload");
const token = core.getInput("token");
// const branch = github.context.payload.pull_request.head.ref;
const branch = "feature/PEWEB-175-custom-domain-for-api-gw";

const client = new NetlifyAPI(token);

console.log("Calling listSiteDeploys");
let deployments = await client.listSiteDeploys({
site_id: site_id,
branch: branch,
});
console.log(`Deployments # ${deployments.length}`);
deployments = deployments.filter((deployment) => deployment.title == title);
console.log(`Filtered # ${deployments.length}`);
// console.log(deployments);

// Output:
// state: 'ready',
// Statuses:
// "new" "pending_review" "accepted" "rejected" "enqueued" "building" "uploading" "uploaded"
// "preparing" "prepared" "processing" "processed" "ready" "error" "retrying"
// deploy_ssl_url: 'https://feature-peweb-175-custom-domain-for-api-gw--sportdog.netlify.app',
// deploy_time: null (in progress) or <int> (if done)
// error_message: null (success) or str (if error)
var deployment = deployments[0];
var deploy_id = deployment.id;
var in_progress = deployment.deploy_time == null;
console.log(
`state: ${deployment.state} (== 'ready': ${deployment.state == "ready"})`
);
console.log(`deploy url: ${deployment.deploy_ssl_url}`);
console.log(`deploy time: ${deployment.deploy_time}`);
console.log(
`error message: ${deployment.error_message} (== null: ${
deployment.error_message == null
})`
);

in_progress = true;
while (in_progress) {
console.log("Sleeping 2 sec");
await new Promise((resolve) => setTimeout(resolve, 2000));
console.log("Sleeping done, updating status");
deployment = await client.getSiteDeploy({
site_id: site_id,
deploy_id: deploy_id,
});
in_progress = deployment.deploy_time == null;
console.log(`Got update. In progress: ${in_progress}`);
}

console.log(
`state: ${deployment.state} (== 'ready': ${deployment.state == "ready"})`
);
console.log(`deploy url: ${deployment.deploy_ssl_url}`);
console.log(`deploy time: ${deployment.deploy_time}`);
console.log(
`error message: ${deployment.error_message} (== null: ${
deployment.error_message == null
})`
);
// Get the JSON webhook payload for the event that triggered the workflow
// const payload = JSON.stringify(github.context.payload, undefined, 2);
// console.log(`The event payload: ${payload}`);
// console.log(`Head Ref: ${github.context.payload.pull_request.head.ref}`);

// const client = new NetlifyAPI("nfp_6oiUkxrMJ4Kh1zhoGTARfLAMzbtVnbPC3e67");
// const sites = await client.listSites();
// console.log(sites);

// console.log("Trying HTTP post");
// let xhr = new XMLHttpRequest();
// xhr.open(
// "POST",
// "https://httpbin.org/post?trigger_branch=GITHUB_HEAD_REF&trigger_title=TITLE"
// );
// xhr.setRequestHeader("Content-Type", "applicathion/json");
// xhr.send(
// JSON.stringify({
// rscEnv: "STAGE",
// cognitoUserPoolId: "COGNITO_USER_POOL_ID",
// cognitoClientId: "COGNITO_CLIENT_ID",
// })
// );
// xhr.onload = function () {
// let resp = xhr.response;
// console.log(`HTTP Response: ${resp.message}`);
// };

// const options = {
// hostname: "httpbin.org",
// port: 443,
// path: "/post",
// method: "POST",
// };

// const req = https.request(options, (res) => {
// console.log("statusCode:", res.statusCode);
// console.log("headers:", res.headers);

// res.on("data", (d) => {
// process.stdout.write(d);
// });
// });

// req.on("error", (e) => {
// console.error(e);
// });
// req.end();
} catch (error) {
core.setFailed(error.message);
}
Loading