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

Update workflows to use specific actions #6

Merged
merged 5 commits into from
Aug 23, 2024
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
78 changes: 39 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- main
pull_request:

schedule:
- cron: 43 2 * * 0
Expand All @@ -25,17 +26,6 @@ jobs:
runs-on: ubuntu-latest

steps:

- uses: docker/setup-qemu-action@v2

- uses: actions/checkout@v4

- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Psalm version to build
run: |
if [[ -z "$PSALM_VERSION" ]]; then
Expand All @@ -53,39 +43,49 @@ jobs:
env:
PSALM_VERSION: ${{ github.event.inputs.psalmVersion }}

- name: Build Docker Image
run: |
docker buildx create --name builder --use
docker buildx build \
--progress plain \
--platform=linux/amd64,linux/arm64 \
--cache-from=ghcr.io/webfactory/psalm:build-cache \
--cache-to=type=registry,ref=ghcr.io/webfactory/psalm:build-cache,mode=max,push=true \
--pull \
--build-arg PSALM_VERSION="$PSALM_VERSION" \
.
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and cache multi-platform image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
build-args: PSALM_VERSION=${{ env.PSALM_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Load image for current platform into local Docker
# see https://github.com/docker/buildx/issues/59 for reason/limitation
uses: docker/build-push-action@v6
with:
build-args: PSALM_VERSION=${{ env.PSALM_VERSION }}
cache-from: type=gha
load: true
tags: build
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false

- name: Run smoke tests
run: |
# Load image for current platform into local Docker (see https://github.com/docker/buildx/issues/59)
docker buildx build \
--progress plain \
--cache-from=ghcr.io/webfactory/psalm:build-cache \
--tag build \
--build-arg PSALM_VERSION="$PSALM_VERSION" \
--load .

# Check "psalm --version" output
docker run --rm build --version | grep -q $PSALM_VERSION

- name: Push image to registry
if: github.event_name != 'pull_request'
run: |
docker buildx build \
--progress plain \
--platform=linux/amd64,linux/arm64 \
--cache-from=ghcr.io/webfactory/psalm:build-cache \
--tag ghcr.io/webfactory/psalm:"$PSALM_VERSION" \
--label org.opencontainers.image.source=https://github.com/webfactory/docker-psalm \
--build-arg PSALM_VERSION="$PSALM_VERSION" \
--push .
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
build-args: PSALM_VERSION=${{ env.PSALM_VERSION }}
cache-from: type=gha
push: true
tags: ghcr.io/webfactory/psalm:${{ env.PSALM_VERSION }}
labels: org.opencontainers.image.source=https://github.com/webfactory/docker-psalm
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM php:8-cli-alpine as build-extensions
FROM php:8-cli-alpine AS build-extensions
RUN docker-php-ext-install pcntl posix
RUN apk add icu-dev
RUN docker-php-ext-configure intl && docker-php-ext-install intl

FROM composer:2 as composer-fetch
FROM composer:2 AS composer-fetch
ARG PSALM_VERSION=*
ENV COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_MEMORY_LIMIT=-1 COMPOSER_NO_INTERACTION=1 COMPOSER_HOME="/composer"
RUN composer global require "vimeo/psalm:$PSALM_VERSION" "psalm/plugin-symfony:*" "psalm/plugin-phpunit:*" "weirdan/doctrine-psalm-plugin:*"

FROM php:8-cli-alpine as runtime
FROM php:8-cli-alpine AS runtime

RUN apk add icu
COPY --from=build-extensions /usr/local/lib/php /usr/local/lib/php
Expand All @@ -26,7 +26,7 @@ RUN chmod +x /entrypoint.sh

# Package container

ENV XDG_CACHE_HOME /cache
ENV XDG_CACHE_HOME=/cache
VOLUME ["/cache"]

WORKDIR "/app"
Expand Down