PHP code example of pierreminiggio / github-action-run-starter-and-artifact-downloader

1. Go to this page and download the library: Download pierreminiggio/github-action-run-starter-and-artifact-downloader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pierreminiggio / github-action-run-starter-and-artifact-downloader example snippets


use PierreMiniggio\GithubActionRunStarterAndArtifactDownloader\GithubActionRunStarterAndArtifactDownloaderFactory;

nActionAndGetArtifacts(
    'token',
    'pierreminiggio',
    'remotion-test-github-action',
    'render-video.yml',
    3,
    0,
    [
        'titleText' => 'Hello from PHP action runner',
        'titleColor' => 'orange'
    ]
);

var_dump($artifacts);

$artifacts = $actionRunner->runActionAndGetArtifacts(
    'token',
    'pierreminiggio',
    'remotion-test-github-action',
    'render-video.yml',
    3,
    0,
    [
        'titleText' => 'Hello from PHP action runner',
        'titleColor' => 'orange'
    ],
    'main',
    true
);

use PierreMiniggio\GithubActionRunStarterAndArtifactDownloader\GithubActionRunStarterAndArtifactDownloaderFactory;

ENCRYPTION_KEY']);

$runTicket = $asyncActionRunner->startAction(
    'token',
    'pierreminiggio',
    'remotion-test-github-action',
    'render-video.yml',
    [
        'titleText' => 'Hello from PHP action runner',
        'titleColor' => 'orange'
    ]
);

// $runTicket is a plain string. Store it wherever you like (a database column,
// a queue message, ...) — it's all checkAction() needs, and it never changes.

$result = $asyncActionRunner->checkAction($runTicket);

if ($result->isPending()) {
    // not finished yet, check again later
} elseif ($result->isFailed()) {
    // something went wrong; getFailureReason() describes what
    echo $result->getFailureReason();
} else {
    // isSuccessful() — artifacts have already been downloaded
    $artifacts = $result->getArtifacts();
}

$actionRunner->setSleepTimeBetweenRunCreationChecks(5); // seconds, defaults to 10
$actionRunner->setNumberOfRunCreationChecksBeforeAssumingItsNotCreated(20); // defaults to 10