Skip to content

Commit

Permalink
feat: add build image workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rancoud committed Nov 27, 2023
1 parent 0a1a981 commit 4e03e80
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: build

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build Image
uses: docker/bake-action@v4
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: image
push: ${{ github.event_name != 'pull_request' }}
6 changes: 5 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ target "php-version" {
}
}

target "ghaction-docker-meta" {
tags = ["blueprintue-self-hosted-edition:local"]
}

group "default" {
targets = ["image-local"]
}
Expand Down Expand Up @@ -51,4 +55,4 @@ target "image" {
target "image-local" {
inherits = ["image"]
output = ["type=docker"]
}
}

0 comments on commit 4e03e80

Please sign in to comment.