ci: migrate to Gitea Actions
CI / policy (push) Successful in 48s
CI / validate (push) Successful in 1m25s
CI / test (push) Successful in 3m43s
CI / build (push) Successful in 1m20s
CI / security (push) Successful in 1m31s
CI / benchmark (push) Failing after 5m52s
CI / images (push) Failing after 1m2s
CI / required (push) Failing after 1s
CI / policy (pull_request) Successful in 9s
CI / validate (pull_request) Successful in 1m6s
CI / test (pull_request) Successful in 3m30s
CI / benchmark (pull_request) Canceled after 3s
CI / build (pull_request) Successful in 1m5s
CI / security (pull_request) Successful in 1m27s
CI / images (pull_request) Successful in 2m24s
CI / required (pull_request) Successful in 5s
CI / policy (push) Successful in 48s
CI / validate (push) Successful in 1m25s
CI / test (push) Successful in 3m43s
CI / build (push) Successful in 1m20s
CI / security (push) Successful in 1m31s
CI / benchmark (push) Failing after 5m52s
CI / images (push) Failing after 1m2s
CI / required (push) Failing after 1s
CI / policy (pull_request) Successful in 9s
CI / validate (pull_request) Successful in 1m6s
CI / test (pull_request) Successful in 3m30s
CI / benchmark (pull_request) Canceled after 3s
CI / build (pull_request) Successful in 1m5s
CI / security (pull_request) Successful in 1m27s
CI / images (pull_request) Successful in 2m24s
CI / required (pull_request) Successful in 5s
This commit is contained in:
1 parent
7d60157863
commit
d74dfb9938
14 files changed
+662
-262
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { readCiContext } from './ci-context.mjs';
|
||||
|
||||
try {
|
||||
const { commit, tag, slug, publish } = readCiContext();
|
||||
if (!publish) throw new Error('Images can only be published by pushes or same-repository PRs.');
|
||||
execFileSync(process.execPath, [fileURLToPath(new URL('./ci-policy.mjs', import.meta.url))]);
|
||||
const env = process.env;
|
||||
if (!env.REGISTRY_USERNAME || !env.REGISTRY_PASSWORD) {
|
||||
throw new Error('REGISTRY_USERNAME and REGISTRY_PASSWORD are required for publication.');
|
||||
}
|
||||
const registry = new URL(env.GITHUB_SERVER_URL).host;
|
||||
const image = `${registry}/${env.GITHUB_REPOSITORY.toLowerCase()}`;
|
||||
const shaImage = `${image}:sha-${commit}`;
|
||||
const docker = (...args) => execFileSync('docker', args, { stdio: 'inherit' });
|
||||
execFileSync(
|
||||
'docker',
|
||||
['login', registry, '--username', env.REGISTRY_USERNAME, '--password-stdin'],
|
||||
{
|
||||
input: env.REGISTRY_PASSWORD,
|
||||
stdio: ['pipe', 'inherit', 'inherit'],
|
||||
},
|
||||
);
|
||||
if (tag) {
|
||||
docker('pull', shaImage);
|
||||
docker('tag', shaImage, `${image}:${tag}`);
|
||||
docker('push', `${image}:${tag}`);
|
||||
docker('tag', shaImage, `${image}:latest`);
|
||||
docker('push', `${image}:latest`);
|
||||
} else {
|
||||
const branchImage = `${image}:branch-${slug}`;
|
||||
docker('build', '-t', shaImage, '-t', branchImage, '.');
|
||||
docker('push', shaImage);
|
||||
docker('push', branchImage);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
Reference in new issue
Block a user