Update workflows to use specific actions #156
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Docker Image | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: 43 2 * * 0 | |
workflow_dispatch: | |
inputs: | |
psalmVersion: | |
description: 'Psalm version to build' | |
required: true | |
default: 'null' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Determine Psalm version to build | |
run: | | |
if [[ -z "$PSALM_VERSION" ]]; then | |
PSALM_VERSION=`curl -sL https://api.github.com/repos/vimeo/psalm/releases/latest | jq -r ".tag_name" | sed -e 's/^v//'` | |
fi | |
if [[ "$PSALM_VERSION" == "null" ]]; then | |
echo "Failed to determine Psalm version to build" | |
exit 1 | |
fi | |
echo "Building Psalm version $PSALM_VERSION" | |
echo "PSALM_VERSION=$PSALM_VERSION" >> $GITHUB_ENV | |
env: | |
PSALM_VERSION: ${{ github.event.inputs.psalmVersion }} | |
- 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: | | |
# Check "psalm --version" output | |
docker run --rm build --version | grep -q $PSALM_VERSION | |
- name: Push image to registry | |
if: github.event_name != 'pull_request' | |
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 |