chore: Add tokenless auth to argos

This commit is contained in:
Sidharth Vinod
2025-02-15 20:28:55 +05:30
parent c5843bee23
commit 3b92f979e3
2 changed files with 26 additions and 1 deletions

View File

@@ -134,6 +134,9 @@ jobs:
ARGOS_PARALLEL: ${{ env.RUN_VISUAL_TEST == 'true' }}
ARGOS_PARALLEL_TOTAL: ${{ env.RUN_VISUAL_TEST == 'true' && strategy.job-total || 1 }}
ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || 1 }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_JOB: ${{ github.job }}
GITHUB_RUN_ID: ${{ github.run_id }}
CYPRESS_COMMIT: ${{ github.sha }}
CYPRESS_RECORD_KEY: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.CYPRESS_RECORD_KEY || ''}}
SPLIT: ${{ strategy.job-total }}

View File

@@ -5,6 +5,14 @@ import { defineConfig } from 'cypress';
import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin';
import cypressSplit from 'cypress-split';
const encodeArgosToken = (options: {
owner: string;
repository: string;
jobId: string;
runId: string;
}) => `tokenless-github-${Buffer.from(JSON.stringify(options), 'utf8').toString('base64')}`;
// cspell:ignore tokenless
export default eyesPlugin(
defineConfig({
projectId: 'n2sma2',
@@ -26,8 +34,22 @@ export default eyesPlugin(
config.env.useArgos = !!process.env.CI && !!process.env.ARGOS_TOKEN;
if (config.env.useArgos) {
if (!process.env.GITHUB_REPOSITORY) {
throw new Error('GITHUB_REPOSITORY is not set');
}
if (!process.env.GITHUB_JOB) {
throw new Error('GITHUB_JOB is not set');
}
if (!process.env.GITHUB_RUN_ID) {
throw new Error('GITHUB_RUN_ID is not set');
}
registerArgosTask(on, config, {
token: 'argos_cde7ec66b3c53730a7bbe4059a517f4a76',
token: encodeArgosToken({
owner: process.env.GITHUB_REPOSITORY.split('/')[0],
repository: process.env.GITHUB_REPOSITORY.split('/')[1],
jobId: process.env.GITHUB_JOB,
runId: process.env.GITHUB_RUN_ID,
}),
});
} else {
addMatchImageSnapshotPlugin(on, config);