From 4e03e80e687e7bc7872c3fbb6c060dfa85b4c23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Thu, 23 Nov 2023 21:41:47 +0100 Subject: [PATCH] feat: add build image workflow --- .github/workflows/build.yml | 57 +++++++++++++++++++++++++++++++++++++ docker-bake.hcl | 6 +++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3d1e605 --- /dev/null +++ b/.github/workflows/build.yml @@ -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' }} diff --git a/docker-bake.hcl b/docker-bake.hcl index f5b5a85..131fc11 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -8,6 +8,10 @@ target "php-version" { } } +target "ghaction-docker-meta" { + tags = ["blueprintue-self-hosted-edition:local"] +} + group "default" { targets = ["image-local"] } @@ -51,4 +55,4 @@ target "image" { target "image-local" { inherits = ["image"] output = ["type=docker"] -} \ No newline at end of file +}