Skip to content

Build

Build #839

Workflow file for this run

name: Build
on:
schedule:
# Everyday at 01:00am
- cron: '0 1 * * *'
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
docker-validate:
strategy:
matrix:
tag: [core, admin]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Docker Lint
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile.grav${{ matrix.tag }}
docker-build-pr:
if: github.event_name == 'pull_request'
needs:
- docker-validate
strategy:
matrix:
tag: [core, admin]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Date
run: |
DATE=$(date +"%Y%m%d")
echo "${DATE}"
echo "DATE=${DATE}" >> $GITHUB_ENV
- name: Get GRAV Version
run: |
GRAV_VERSION=$(curl -sL "https://api.github.com/repos/getgrav/grav/releases/latest" | grep tag_name | cut -d '"' -f 4)
echo "${GRAV_VERSION}"
echo "GRAV_VERSION=${GRAV_VERSION}" >> $GITHUB_ENV
- name: Generate Docker Metadata
id: docker-meta
uses: docker/metadata-action@v5
with:
images: |
dsavell/grav
tags: |
type=raw,value=${{ matrix.tag }}
type=raw,value=${{ matrix.tag }}-${{ env.GRAV_VERSION }}
type=raw,value=${{ matrix.tag }}-${{ env.DATE }}
type=raw,value=${{ matrix.tag }}-${{ env.GRAV_VERSION }}-${{ env.DATE }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build only
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.grav${{ matrix.tag }}
push: false
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
GRAV_VERSION=${{ env.GRAV_VERSION }}
docker-build-main:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs:
- docker-validate
strategy:
matrix:
tag: [core, admin]
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Date
run: |
DATE=$(date +"%Y%m%d")
echo "${DATE}"
echo "DATE=${DATE}" >> $GITHUB_ENV
- name: Get GRAV Version
run: |
GRAV_VERSION=$(curl -sL "https://api.github.com/repos/getgrav/grav/releases/latest" | grep tag_name | cut -d '"' -f 4)
echo "${GRAV_VERSION}"
echo "GRAV_VERSION=${GRAV_VERSION}" >> $GITHUB_ENV
- name: Generate Docker Metadata
id: docker-meta
uses: docker/metadata-action@v5
with:
images: |
dsavell/grav
tags: |
type=raw,value=${{ matrix.tag }}
type=raw,value=${{ matrix.tag }}-${{ env.GRAV_VERSION }}
type=raw,value=${{ matrix.tag }}-${{ env.DATE }}
type=raw,value=${{ matrix.tag }}-${{ env.GRAV_VERSION }}-${{ env.DATE }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.grav${{ matrix.tag }}
push: true
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
GRAV_VERSION=${{ env.GRAV_VERSION }}