Skip to content

Refactor GitHub workflows and update Docker actions #90

Refactor GitHub workflows and update Docker actions

Refactor GitHub workflows and update Docker actions #90

Workflow file for this run

name: build
on:
push:
branches:
- '1.x'
tags:
- 'v*'
pull_request:
branches:
- '1.x'
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/sitepilot/runtime
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
- name: Build test image
uses: docker/build-push-action@v5
with:
context: ./src
load: true
tags: ghcr.io/sitepilot/runtime:build
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run unit tests
run: |
docker run ghcr.io/sitepilot/runtime:build id
docker run --user=root -e RUNTIME_PASSWORD=supersecret ghcr.io/sitepilot/runtime:build id app
docker run --user=root -e RUNTIME_UID=1001 -e RUNTIME_GID=1001 ghcr.io/sitepilot/runtime:build id app
docker run --user=root -e RUNTIME_USER=test-user -e RUNTIME_GROUP=test-group ghcr.io/sitepilot/runtime:build id test-user
- name: Build and publish image
uses: docker/build-push-action@v5
with:
context: ./src
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64, linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false