Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Feb 20, 2025
1 parent 4dbc32b commit 68c27ee
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ jobs:
with:
fetch-depth: 0 # required for composer to automatically detect root package version

- name: Get Composer Cache Directories
id: composer-cache
run: |
echo "files_cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "vcs_cache=$(composer config cache-vcs-dir)" >> $GITHUB_OUTPUT
- name: Generate composer.lock
run: |
composer update --no-install
- name: Cache composer cache
uses: actions/cache@v4
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
${{ steps.composer-cache.outputs.vcs_cache }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Run composer install
run: composer install -o
# DO NOT set this, we need composer to figure out the version itself
# env:
# COMPOSER_ROOT_VERSION: dev-master

- name: Upload docker image
env:
EVENT_NAME: ${{ github.event_name }}
Expand Down
25 changes: 20 additions & 5 deletions bin/ci/build-docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

declare(strict_types=1);

use Amp\Process\Process;

use function Amp\ByteStream\getStderr;
use function Amp\ByteStream\getStdout;
use function Amp\ByteStream\pipe;
use function Amp\async;

require 'vendor/autoload.php';

$commit = getenv('GITHUB_SHA');
$ref = substr(getenv('REF'), strlen('refs/heads/'));
$is_tag = getenv('EVENT_NAME') === 'release';
Expand All @@ -11,8 +20,11 @@

function r(string $cmd): void
{
echo "> $cmd\n";
passthru($cmd);
getStderr()->write("> $cmd\n");
$cmd = Process::start($cmd);
async(pipe(...), $cmd->getStdout(), getStdout())->ignore();
async(pipe(...), $cmd->getStderr(), getStderr())->ignore();
$cmd->join();
}

$composer_branch = $is_tag ? $ref : "dev-$ref";
Expand All @@ -33,10 +45,13 @@ function r(string $cmd): void
$cur++;
}

passthru("docker build . -t ghcr.io/vimeo/psalm:$branch --build-arg PSALM_REV=$compose_branch -f bin/docker/Dockerfile");
passthru("docker push ghcr.io/vimeo/psalm:$branch");
$ref = escapeshellarg($ref);
$composer_branch = escapeshellarg($composer_branch);

passthru("docker build . -t ghcr.io/vimeo/psalm:$ref --build-arg PSALM_REV=$composer_branch -f bin/docker/Dockerfile");
passthru("docker push ghcr.io/vimeo/psalm:$ref");

if ($is_tag) {
passthru("docker tag ghcr.io/vimeo/psalm:$branch ghcr.io/vimeo/psalm:latest");
passthru("docker tag ghcr.io/vimeo/psalm:$ref ghcr.io/vimeo/psalm:latest");
passthru("docker push ghcr.io/vimeo/psalm:latest");
}

0 comments on commit 68c27ee

Please sign in to comment.