Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanc main #1

Merged
merged 21 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ deploy:
GIGALIXIR_CLEAN: true # defaults to false
GIGALIXIR_USERNAME: ${{ secrets.GIGALIXIR_USERNAME }}
GIGALIXIR_PASSWORD: ${{ secrets.GIGALIXIR_PASSWORD }}
MAX_RETRY_ATTEMPTS: 10 # Max number of times to retry Gigalixir API calls. Retries happen every 10 seconds. The default is 60
MIGRATIONS: false # defaults to true
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
```
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
GIGALIXIR_PASSWORD:
description: 'Your Gigalixir password'
required: true
MAX_RETRY_ATTEMPTS:
description: 'Maximum number of request retry attempts when communicating with Gigalixir'
default: "60"
MIGRATIONS:
description: 'Configuration for migrations'
required: true
Expand Down
15 changes: 8 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27590,15 +27590,13 @@ async function isNextReleaseHealthy(release, app) {
return releases.pods.filter((pod) => (Number(pod.version) === release && pod.status === "Healthy")).length >= releases.replicas_desired;
}

async function waitForNewRelease(oldRelease, app, attempts) {
const maxAttempts = 60;

if (await isNextReleaseHealthy(oldRelease + 1, app)) {
async function waitForNewRelease(oldRelease, newRelease, app, attempts, maxAttempts) {
if (await isNextReleaseHealthy(newRelease, app)) {
return await Promise.resolve(true);
} else {
if (attempts <= maxAttempts) {
await wait(10);
await waitForNewRelease(oldRelease, app, attempts + 1);
await waitForNewRelease(oldRelease, newRelease, app, attempts + 1, maxAttempts);
} else {
throw "Taking too long for new release to deploy";
}
Expand Down Expand Up @@ -27643,6 +27641,7 @@ async function run() {
const gigalixirClean = core.getInput('GIGALIXIR_CLEAN', { required: false });
const gigalixirUsername = core.getInput('GIGALIXIR_USERNAME', { required: true });
const gigalixirPassword = core.getInput('GIGALIXIR_PASSWORD', { required: true });
const maxRetryAttempts = Number(core.getInput('MAX_RETRY_ATTEMPTS', { required: false }));
const migrations = core.getInput('MIGRATIONS', { required: true });
const sshPrivateKey = core.getInput('SSH_PRIVATE_KEY', { required: JSON.parse(migrations) });

Expand Down Expand Up @@ -27677,8 +27676,10 @@ async function run() {
await exec.exec(path.join(__dirname, "../bin/add-private-key"), [sshPrivateKey]);
});

await core.group("Waiting for new release to deploy", async () => {
await waitForNewRelease(currentRelease, gigalixirApp, 1);
const newRelease = await getCurrentRelease(gigalixirApp);

await core.group(`Waiting for new release to deploy: ${newRelease}`, async () => {
await waitForNewRelease(currentRelease, newRelease, gigalixirApp, 1, maxRetryAttempts);
});

try {
Expand Down
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ async function isNextReleaseHealthy(release, app) {
return releases.pods.filter((pod) => (Number(pod.version) === release && pod.status === "Healthy")).length >= releases.replicas_desired;
}

async function waitForNewRelease(oldRelease, app, attempts) {
const maxAttempts = 60;

if (await isNextReleaseHealthy(oldRelease + 1, app)) {
async function waitForNewRelease(oldRelease, newRelease, app, attempts, maxAttempts) {
if (await isNextReleaseHealthy(newRelease, app)) {
return await Promise.resolve(true);
} else {
if (attempts <= maxAttempts) {
await wait(10);
await waitForNewRelease(oldRelease, app, attempts + 1);
await waitForNewRelease(oldRelease, newRelease, app, attempts + 1, maxAttempts);
} else {
throw "Taking too long for new release to deploy";
}
Expand Down Expand Up @@ -86,6 +84,7 @@ async function run() {
const gigalixirClean = core.getInput('GIGALIXIR_CLEAN', { required: false });
const gigalixirUsername = core.getInput('GIGALIXIR_USERNAME', { required: true });
const gigalixirPassword = core.getInput('GIGALIXIR_PASSWORD', { required: true });
const maxRetryAttempts = Number(core.getInput('MAX_RETRY_ATTEMPTS', { required: false }));
const migrations = core.getInput('MIGRATIONS', { required: true });
const sshPrivateKey = core.getInput('SSH_PRIVATE_KEY', { required: JSON.parse(migrations) });

Expand Down Expand Up @@ -120,8 +119,10 @@ async function run() {
await exec.exec(path.join(__dirname, "../bin/add-private-key"), [sshPrivateKey]);
});

await core.group("Waiting for new release to deploy", async () => {
await waitForNewRelease(currentRelease, gigalixirApp, 1);
const newRelease = await getCurrentRelease(gigalixirApp);

await core.group(`Waiting for new release to deploy: ${newRelease}`, async () => {
await waitForNewRelease(currentRelease, newRelease, gigalixirApp, 1, maxRetryAttempts);
});

try {
Expand Down
Loading