Sail Publish #14
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: Sail Publish | |
on: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Copy .env | |
run: | | |
if [[ ! -f '.env' ]];then | |
cp '.env.example' '.env' | |
fi | |
- name: Dotenv Action | |
uses: falti/dotenv-action@v1 | |
with: | |
export-variables: true | |
keys-case: upper | |
- name: Install Dependencies | |
run: | | |
composer update --lock | |
composer require laravel/sail -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=tag | |
type=semver,pattern={{raw}} | |
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Europe/Amsterdam'}} | |
type=sha | |
# Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ github.workspace }}/vendor/laravel/sail/runtimes/${{ env.SAIL_VERSION }} | |
build-args: WWWGROUP=${{ env.WWWGROUP }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |